diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:23:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:23:53 +0000 |
commit | c000cad09d0b54c455c99271bfb996c2dfe13073 (patch) | |
tree | e47ca809ed512d7fb43ec3d555753b1b658e9819 /contrib/ldapc++/src/LDAPExtRequest.cpp | |
parent | Initial commit. (diff) | |
download | openldap-c000cad09d0b54c455c99271bfb996c2dfe13073.tar.xz openldap-c000cad09d0b54c455c99271bfb996c2dfe13073.zip |
Adding upstream version 2.4.47+dfsg.upstream/2.4.47+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/ldapc++/src/LDAPExtRequest.cpp')
-rw-r--r-- | contrib/ldapc++/src/LDAPExtRequest.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/ldapc++/src/LDAPExtRequest.cpp b/contrib/ldapc++/src/LDAPExtRequest.cpp new file mode 100644 index 0000000..853c452 --- /dev/null +++ b/contrib/ldapc++/src/LDAPExtRequest.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include <ldap.h> +#include <lber.h> + +#include "debug.h" + +#include "LDAPExtRequest.h" +#include "LDAPException.h" +#include "LDAPResult.h" + +#include <cstdlib> + +using namespace std; + +LDAPExtRequest::LDAPExtRequest(const LDAPExtRequest& req) : + LDAPRequest(req){ + DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPExtRequest::LDAPExtRequest(&)" << endl); + m_data=req.m_data; + m_oid=req.m_oid; +} + +LDAPExtRequest::LDAPExtRequest(const string& oid, const string& data, + LDAPAsynConnection *connect, const LDAPConstraints *cons, + bool isReferral, const LDAPRequest* parent) + : LDAPRequest(connect, cons, isReferral, parent){ + DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPExtRequest::LDAPExtRequest()" << endl); + DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, + " oid:" << oid << endl); + m_oid=oid; + m_data=data; +} + +LDAPExtRequest::~LDAPExtRequest(){ + DEBUG(LDAP_DEBUG_DESTROY, "LDAPExtRequest::~LDAPExtRequest()" << endl); +} + +LDAPMessageQueue* LDAPExtRequest::sendRequest(){ + DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::sendRequest()" << endl); + int msgID=0; + BerValue* tmpdata=0; + if(m_data != ""){ + tmpdata=(BerValue*) malloc(sizeof(BerValue)); + tmpdata->bv_len = m_data.size(); + tmpdata->bv_val = (char*) malloc(sizeof(char) * (m_data.size()) ); + m_data.copy(tmpdata->bv_val, string::npos); + } + LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray(); + LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); + int err=ldap_extended_operation(m_connection->getSessionHandle(), + m_oid.c_str(), tmpdata, tmpSrvCtrls, tmpClCtrls, &msgID); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); + ber_bvfree(tmpdata); + if(err != LDAP_SUCCESS){ + delete this; + throw LDAPException(err); + }else{ + m_msgID=msgID; + return new LDAPMessageQueue(this); + } +} + +LDAPRequest* LDAPExtRequest::followReferral(LDAPMsg* ref){ + DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::followReferral()" << endl); + 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 LDAPExtRequest(m_oid, m_data, con, m_cons,true,this); + } + return 0; +} + + |