]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPBindRequest.cpp
4a39e3e21b366fcc30879b124357aeeb63479476
[openldap] / contrib / ldapc++ / src / LDAPBindRequest.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include <ldap.h>
7
8 #include "debug.h"
9
10 #include "LDAPBindRequest.h"
11 #include "LDAPException.h"
12
13 LDAPBindRequest::LDAPBindRequest(const LDAPBindRequest& req) :
14         LDAPRequest(req){
15     DEBUG(LDAP_DEBUG_TRACE, 
16             "LDAPBindRequest::LDAPBindRequest(LDAPBindRequest&)" << endl);
17 }
18
19 LDAPBindRequest::LDAPBindRequest(const char *dn, const char *passwd, 
20         const LDAPAsynConnection *connect, const LDAPConstraints *cons,
21         bool isReferral=false) : LDAPRequest(connect, cons, isReferral){
22    DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::LDAPBindRequest()" << endl);
23    DEBUG(LDAP_DEBUG_PARAMETER, "   dn:" << dn << endl
24            << "   passwd:" << passwd << endl);
25     m_dn = strdup(dn);
26     m_cred = ber_bvstr(passwd);
27     m_mech = LDAP_SASL_SIMPLE;
28 }
29
30 LDAPBindRequest::~LDAPBindRequest(){
31     DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::~LDAPBindRequest()" << endl);
32     delete[] m_dn;
33     ber_bvfree(m_cred);
34     delete[] m_mech;
35 }
36
37 LDAPMessageQueue* LDAPBindRequest::sendRequest(){
38     DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::sendRequest()" << endl);
39     int msgID=0;
40     int err=ldap_sasl_bind(m_connection->getSessionHandle(),m_dn, 
41             m_mech, m_cred, m_cons->getSrvCtrlsArray(),
42             m_cons->getClCtrlsArray(),&msgID);
43     if(err != LDAP_SUCCESS){
44         delete this;
45         throw LDAPException(err);
46     }else{
47         m_msgID=msgID;
48         return new LDAPMessageQueue(this);
49     }
50 }
51
52 LDAPRequest* LDAPBindRequest::followReferral(LDAPUrlList *urls){
53     DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::followReferral()" << endl);
54     return 0;
55 }
56