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 "LDAPModDNRequest.h"
|
|
|
|
|
#include "LDAPException.h"
|
2000-10-03 14:25:34 -04:00
|
|
|
#include "LDAPResult.h"
|
2000-09-01 14:46:32 -04:00
|
|
|
#include "LDAPUrlList.h"
|
|
|
|
|
|
2001-09-28 12:39:58 -04:00
|
|
|
using namespace std;
|
|
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
LDAPModDNRequest::LDAPModDNRequest(const LDAPModDNRequest& req) :
|
|
|
|
|
LDAPRequest(req){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPModDNRequest::LDAPModDNRequest(&)" << endl);
|
|
|
|
|
m_dn = req.m_dn;
|
|
|
|
|
m_newRDN = req.m_newRDN;
|
|
|
|
|
m_newParentDN = req.m_newParentDN;
|
|
|
|
|
m_deleteOld = req.m_deleteOld;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPModDNRequest::LDAPModDNRequest(const string& dn, const string& newRDN,
|
|
|
|
|
bool deleteOld, const string& newParentDN,
|
|
|
|
|
LDAPAsynConnection *connect,
|
|
|
|
|
const LDAPConstraints *cons, bool isReferral,
|
|
|
|
|
const LDAPRequest* parent):
|
|
|
|
|
LDAPRequest(connect, cons, isReferral, parent){
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,
|
|
|
|
|
"LDAPModDNRequest::LDAPModDNRequest(&)" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
|
|
|
|
|
" dn:" << dn << endl << " newRDN:" << newRDN << endl
|
|
|
|
|
<< " deleteOld:" << deleteOld << endl
|
|
|
|
|
<< " newParent:" << newParentDN << endl);
|
|
|
|
|
m_dn = dn;
|
|
|
|
|
m_newRDN = newRDN;
|
|
|
|
|
m_newParentDN = newParentDN;
|
2000-09-01 14:46:32 -04:00
|
|
|
m_deleteOld=deleteOld;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPModDNRequest::~LDAPModDNRequest(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_DESTROY, "LDAPModDNRequest::~LDAPModDNRequest()" << endl);
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPMessageQueue* LDAPModDNRequest::sendRequest(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE, "LDAPModDNRequest::sendRequest()" << endl);
|
2000-09-01 14:46:32 -04:00
|
|
|
int msg_id;
|
2000-10-03 14:25:34 -04:00
|
|
|
const char* newRDN = (m_newRDN == "" ? 0 :m_newRDN.c_str());
|
|
|
|
|
const char* newParentDN = (m_newParentDN == "" ?
|
|
|
|
|
0 :
|
|
|
|
|
m_newParentDN.c_str());
|
|
|
|
|
LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray();
|
|
|
|
|
LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray();
|
|
|
|
|
int err=ldap_rename(m_connection->getSessionHandle(),m_dn.c_str(),newRDN,
|
|
|
|
|
newParentDN,m_deleteOld ? 1 : 0, tmpSrvCtrls, tmpClCtrls,&msg_id);
|
2001-11-14 12:33:54 -05:00
|
|
|
LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls);
|
|
|
|
|
LDAPControlSet::freeLDAPControlArray(tmpClCtrls);
|
2000-09-01 14:46:32 -04:00
|
|
|
if(err!=LDAP_SUCCESS){
|
|
|
|
|
throw LDAPException(err);
|
|
|
|
|
}else{
|
|
|
|
|
m_msgID=msg_id;
|
|
|
|
|
return new LDAPMessageQueue(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPRequest* LDAPModDNRequest::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 LDAPModDNRequest(m_dn, m_newRDN, m_deleteOld, m_newParentDN,
|
|
|
|
|
con, m_cons,true,this);
|
|
|
|
|
}
|
2000-09-01 14:46:32 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|