2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include "LDAPDeleteRequest.h"
11 #include "LDAPException.h"
12 #include "LDAPMessageQueue.h"
13 #include "LDAPResult.h"
15 LDAPDeleteRequest::LDAPDeleteRequest( const LDAPDeleteRequest& req) :
17 DEBUG(LDAP_DEBUG_CONSTRUCT,
18 "LDAPDeleteRequest::LDAPDeleteRequest(&)" << endl);
22 LDAPDeleteRequest::LDAPDeleteRequest(const string& dn,
23 LDAPAsynConnection *connect, const LDAPConstraints *cons,
24 bool isReferral, const LDAPRequest* parent)
25 : LDAPRequest(connect, cons, isReferral, parent) {
26 DEBUG(LDAP_DEBUG_CONSTRUCT,
27 "LDAPDeleteRequest::LDAPDeleteRequest()" << endl);
28 DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " dn:" << dn << endl);
29 m_requestType=LDAPRequest::DELETE;
33 LDAPDeleteRequest::~LDAPDeleteRequest(){
34 DEBUG(LDAP_DEBUG_DESTROY,
35 "LDAPDeleteRequest::~LDAPDeleteRequest()" << endl);
36 // TODO -- flush the entire cache here? or does this invalidate
37 // cached searches that may have found the deleted entry.
38 m_connection->uncache_entry(m_dn);
41 LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){
42 DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::sendRequest()" << endl);
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 ldap_controls_free(tmpSrvCtrls);
49 ldap_controls_free(tmpClCtrls);
50 if(err != LDAP_SUCCESS){
51 throw LDAPException(err);
54 return new LDAPMessageQueue(this);
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;
64 con = getConnection()->referralConnect(urls,usedUrl,m_cons);
65 }catch (LDAPException e){
70 return new LDAPDeleteRequest(m_dn, con, m_cons, true, this);