2000-09-01 14:46:32 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <ldap.h>
|
|
|
|
|
|
2000-10-11 13:18:27 -04:00
|
|
|
#include "debug.h"
|
2000-09-01 14:46:32 -04:00
|
|
|
|
|
|
|
|
#include "LDAPModifyRequest.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
|
|
|
|
|
|
|
|
LDAPModifyRequest::LDAPModifyRequest(const LDAPModifyRequest& req) :
|
|
|
|
|
LDAPRequest(req){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPModifyRequest::LDAPModifyRequest(&)" << endl);
|
|
|
|
|
m_modList = new LDAPModList(*(req.m_modList));
|
|
|
|
|
m_dn = req.m_dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPModifyRequest::LDAPModifyRequest(const string& dn,
|
|
|
|
|
const LDAPModList *modList, LDAPAsynConnection *connect,
|
|
|
|
|
const LDAPConstraints *cons, bool isReferral,
|
|
|
|
|
const LDAPRequest* parent) :
|
|
|
|
|
LDAPRequest(connect, cons, isReferral, parent){
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPModifyRequest::LDAPModifyRequest(&)" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
|
|
|
|
|
" dn:" << dn << endl);
|
|
|
|
|
m_dn = dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
m_modList = new LDAPModList(*modList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPModifyRequest::~LDAPModifyRequest(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_DESTROY,
|
|
|
|
|
"LDAPModifyRequest::~LDAPModifyRequest()" << endl);
|
2000-09-01 14:46:32 -04:00
|
|
|
delete m_modList;
|
2001-05-04 10:38:13 -04:00
|
|
|
// flush this entry from cache.
|
|
|
|
|
m_connection->uncache_entry(m_dn);
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPMessageQueue* LDAPModifyRequest::sendRequest(){
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE, "LDAPModifyRequest::sendRequest()" << endl);
|
|
|
|
|
int msgID=0;
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray();
|
|
|
|
|
LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray();
|
|
|
|
|
LDAPMod** tmpMods=m_modList->toLDAPModArray();
|
|
|
|
|
int err=ldap_modify_ext(m_connection->getSessionHandle(),m_dn.c_str(),
|
|
|
|
|
tmpMods, 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* LDAPModifyRequest::followReferral(LDAPMsg* ref){
|
2000-09-01 14:46:32 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE, "LDAPModifyRequest::followReferral()" << endl);
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPUrlList::const_iterator usedUrl;
|
|
|
|
|
LDAPUrlList urls = ((LDAPResult*)ref)->getReferralUrls();
|
|
|
|
|
LDAPAsynConnection* con = 0;
|
|
|
|
|
try {
|
|
|
|
|
con = getConnection()->referralConnect(urls,usedUrl,m_cons);
|
|
|
|
|
} catch(LDAPException e){
|
|
|
|
|
delete con;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if(con != 0){
|
|
|
|
|
return new LDAPModifyRequest(m_dn, m_modList, con, m_cons,true,this);
|
|
|
|
|
}
|
2000-09-01 14:46:32 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
|