]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPExtRequest.cpp
Initial check of the LDAP C++ SDK written by Ralf Haferkamp <rhafer@suse.de>
[openldap] / contrib / ldapc++ / src / LDAPExtRequest.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include <ldap.h>
7 #include <lber.h>
8
9 #include "debug.h"
10
11 #include "LDAPExtRequest.h"
12 #include "LDAPException.h"
13
14 LDAPExtRequest::LDAPExtRequest(const LDAPExtRequest& req) :
15         LDAPRequest(req){
16     DEBUG(LDAP_DEBUG_TRACE,
17             "LDAPExtRequest::LDAPExtRequest(LDAPExtRequest&)" << endl);
18 }
19
20 LDAPExtRequest::LDAPExtRequest(const char *oid, const BerValue* data, 
21         const LDAPAsynConnection *connect, const LDAPConstraints *cons,
22         bool isReferral=false) : LDAPRequest(connect, cons, isReferral){
23     DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::LDAPExtRequest()" << endl);
24     DEBUG(LDAP_DEBUG_PARAMETER, "   oid:" << oid << endl);
25     assert(oid);
26     m_oid=strdup(oid);
27     if(data){
28         m_data=ber_bvdup(data);
29     }else{
30         m_data=0;
31     }
32 }
33
34 LDAPExtRequest::~LDAPExtRequest(){
35     DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::~LDAPExtRequest()" << endl);
36     delete[] m_oid;
37     ber_bvfree(m_data);
38 }
39
40 LDAPMessageQueue* LDAPExtRequest::sendRequest(){
41     DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::sendRequest()" << endl);
42     int msgID=0;
43     int err=ldap_extended_operation(m_connection->getSessionHandle(),m_oid, 
44             m_data, m_cons->getSrvCtrlsArray(), m_cons->getClCtrlsArray(),
45             &msgID);
46     if(err != LDAP_SUCCESS){
47         delete this;
48         throw LDAPException(err);
49     }else{
50         m_msgID=msgID;
51         return new LDAPMessageQueue(this);
52     }
53 }
54
55 LDAPRequest* LDAPExtRequest::followReferral(LDAPUrlList *urls){
56     DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::followReferral()" << endl);
57     cerr << "to be implemented" << endl;
58     return 0;
59 }
60