2000-09-01 14:46:32 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <ldap.h>
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
|
#include "LDAPDeleteRequest.h"
|
|
|
|
|
#include "LDAPException.h"
|
|
|
|
|
#include "LDAPMessageQueue.h"
|
2000-10-03 14:25:34 -04:00
|
|
|
#include "LDAPResult.h"
|
2000-09-01 14:46:32 -04:00
|
|
|
|
|
|
|
|
LDAPDeleteRequest::LDAPDeleteRequest( const LDAPDeleteRequest& req) :
|
|
|
|
|
LDAPRequest(req){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPDeleteRequest::LDAPDeleteRequest(&)" << endl);
|
|
|
|
|
m_dn = req.m_dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPDeleteRequest::LDAPDeleteRequest(const string& dn,
|
|
|
|
|
LDAPAsynConnection *connect, const LDAPConstraints *cons,
|
|
|
|
|
bool isReferral, const LDAPRequest* parent)
|
|
|
|
|
: LDAPRequest(connect, cons, isReferral, parent) {
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPDeleteRequest::LDAPDeleteRequest()" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " dn:" << dn << endl);
|
2000-09-01 14:46:32 -04:00
|
|
|
m_requestType=LDAPRequest::DELETE;
|
2000-10-03 14:25:34 -04:00
|
|
|
m_dn=dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPDeleteRequest::~LDAPDeleteRequest(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_DESTROY,
|
|
|
|
|
"LDAPDeleteRequest::~LDAPDeleteRequest()" << endl);
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::sendRequest()" << endl);
|
|
|
|
|
int msgID=0;
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray();
|
|
|
|
|
LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray();
|
|
|
|
|
int err=ldap_delete_ext(m_connection->getSessionHandle(),m_dn.c_str(),
|
|
|
|
|
tmpSrvCtrls, tmpClCtrls ,&msgID);
|
|
|
|
|
ldap_controls_free(tmpSrvCtrls);
|
|
|
|
|
ldap_controls_free(tmpClCtrls);
|
2000-09-01 14:46:32 -04:00
|
|
|
if(err != LDAP_SUCCESS){
|
|
|
|
|
throw LDAPException(err);
|
|
|
|
|
}else{
|
|
|
|
|
m_msgID=msgID;
|
|
|
|
|
return new LDAPMessageQueue(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPRequest* LDAPDeleteRequest::followReferral(LDAPMsg* refs){
|
2000-09-01 14:46:32 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE, "LDAPDeleteRequest::followReferral()" << endl);
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPUrlList::const_iterator usedUrl;
|
|
|
|
|
LDAPUrlList urls= ((LDAPResult*)refs)->getReferralUrls();
|
|
|
|
|
LDAPAsynConnection* con=0;
|
|
|
|
|
try{
|
|
|
|
|
con = getConnection()->referralConnect(urls,usedUrl,m_cons);
|
|
|
|
|
}catch (LDAPException e){
|
|
|
|
|
delete con;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if(con != 0){
|
|
|
|
|
return new LDAPDeleteRequest(m_dn, con, m_cons, true, this);
|
|
|
|
|
}
|
2000-09-01 14:46:32 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
|