| 1 |
// $OpenLDAP$ |
| 2 |
/* |
| 3 |
* Copyright 2000-2024 The OpenLDAP Foundation, All Rights Reserved. |
| 4 |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <ldap.h> |
| 8 |
|
| 9 |
#include "debug.h" |
| 10 |
|
| 11 |
#include "LDAPDeleteRequest.h" |
| 12 |
#include "LDAPException.h" |
| 13 |
#include "LDAPMessageQueue.h" |
| 14 |
#include "LDAPResult.h" |
| 15 |
|
| 16 |
using namespace std; |
| 17 |
|
| 18 |
LDAPDeleteRequest::LDAPDeleteRequest( const LDAPDeleteRequest& req) : |
| 19 |
LDAPRequest(req){ |
| 20 |
DEBUG(LDAP_DEBUG_CONSTRUCT, |
| 21 |
"LDAPDeleteRequest::LDAPDeleteRequest(&)" << endl); |
| 22 |
m_dn = req.m_dn; |
| 23 |
} |
| 24 |
|
| 25 |
LDAPDeleteRequest::LDAPDeleteRequest(const string& dn, |
| 26 |
LDAPAsynConnection *connect, const LDAPConstraints *cons, |
| 27 |
bool isReferral, const LDAPRequest* parent) |
| 28 |
: LDAPRequest(connect, cons, isReferral, parent) { |
| 29 |
DEBUG(LDAP_DEBUG_CONSTRUCT, |
| 30 |
"LDAPDeleteRequest::LDAPDeleteRequest()" << endl); |
| 31 |
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " dn:" << dn << endl); |
| 32 |
m_requestType=LDAPRequest::DELETE; |
| 33 |
m_dn=dn; |
| 34 |
} |
| 35 |
|
| 36 |
LDAPDeleteRequest::~LDAPDeleteRequest(){ |
| 37 |
DEBUG(LDAP_DEBUG_DESTROY, |
| 38 |
"LDAPDeleteRequest::~LDAPDeleteRequest()" << endl); |
| 39 |
} |
| 40 |
|
| 41 |
LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){ |
| 42 |
DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::sendRequest()" << endl); |
| 43 |
int msgID=0; |
| 44 |
LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray(); |
| 45 |
LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); |
| 46 |
int err=ldap_delete_ext(m_connection->getSessionHandle(),m_dn.c_str(), |
| 47 |
tmpSrvCtrls, tmpClCtrls ,&msgID); |
| 48 |
LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); |
| 49 |
LDAPControlSet::freeLDAPControlArray(tmpClCtrls); |
| 50 |
if(err != LDAP_SUCCESS){ |
| 51 |
throw LDAPException(err); |
| 52 |
}else{ |
| 53 |
m_msgID=msgID; |
| 54 |
return new LDAPMessageQueue(this); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
LDAPRequest* LDAPDeleteRequest::followReferral(LDAPMsg* refs){ |
| 59 |
DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::followReferral()" << endl); |
| 60 |
LDAPUrlList::const_iterator usedUrl; |
| 61 |
LDAPUrlList urls= ((LDAPResult*)refs)->getReferralUrls(); |
| 62 |
LDAPAsynConnection* con=0; |
| 63 |
try{ |
| 64 |
con = getConnection()->referralConnect(urls,usedUrl,m_cons); |
| 65 |
}catch (LDAPException e){ |
| 66 |
delete con; |
| 67 |
return 0; |
| 68 |
} |
| 69 |
if(con != 0){ |
| 70 |
return new LDAPDeleteRequest(m_dn, con, m_cons, true, this); |
| 71 |
} |
| 72 |
return 0; |
| 73 |
} |
| 74 |
|
| 75 |
|