Back to index

openldap  2.4.31
LDAPDeleteRequest.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 #include <ldap.h>
00008 
00009 #include "debug.h"
00010 
00011 #include "LDAPDeleteRequest.h"
00012 #include "LDAPException.h"
00013 #include "LDAPMessageQueue.h"
00014 #include "LDAPResult.h"
00015 
00016 using namespace std;
00017 
00018 LDAPDeleteRequest::LDAPDeleteRequest( const LDAPDeleteRequest& req) :
00019         LDAPRequest(req){
00020        DEBUG(LDAP_DEBUG_CONSTRUCT, 
00021               "LDAPDeleteRequest::LDAPDeleteRequest(&)" << endl);
00022     m_dn = req.m_dn;
00023 }
00024 
00025 LDAPDeleteRequest::LDAPDeleteRequest(const string& dn, 
00026         LDAPAsynConnection *connect, const LDAPConstraints *cons,
00027         bool isReferral, const LDAPRequest* parent) 
00028         : LDAPRequest(connect, cons, isReferral, parent) {
00029        DEBUG(LDAP_DEBUG_CONSTRUCT,
00030             "LDAPDeleteRequest::LDAPDeleteRequest()" << endl);
00031        DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, "   dn:" << dn << endl);
00032     m_requestType=LDAPRequest::DELETE;
00033     m_dn=dn;
00034 }
00035 
00036 LDAPDeleteRequest::~LDAPDeleteRequest(){
00037     DEBUG(LDAP_DEBUG_DESTROY,
00038           "LDAPDeleteRequest::~LDAPDeleteRequest()" << endl);
00039 }
00040 
00041 LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){
00042        DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::sendRequest()" << endl);
00043     int msgID=0;
00044     LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray();
00045     LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray();
00046     int err=ldap_delete_ext(m_connection->getSessionHandle(),m_dn.c_str(), 
00047             tmpSrvCtrls, tmpClCtrls ,&msgID);
00048     LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls);
00049     LDAPControlSet::freeLDAPControlArray(tmpClCtrls);
00050     if(err != LDAP_SUCCESS){
00051         throw LDAPException(err);
00052     }else{
00053         m_msgID=msgID;
00054         return new LDAPMessageQueue(this);
00055     }
00056 }
00057 
00058 LDAPRequest* LDAPDeleteRequest::followReferral(LDAPMsg* refs){
00059        DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::followReferral()" << endl);
00060     LDAPUrlList::const_iterator usedUrl;
00061     LDAPUrlList urls= ((LDAPResult*)refs)->getReferralUrls();
00062     LDAPAsynConnection* con=0;
00063     try{
00064         con = getConnection()->referralConnect(urls,usedUrl,m_cons);
00065     }catch (LDAPException e){
00066         delete con;
00067         return 0;
00068     }
00069     if(con != 0){
00070         return new LDAPDeleteRequest(m_dn, con, m_cons, true, this);
00071     }
00072     return 0;
00073 }
00074 
00075