2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include "LDAPBindRequest.h"
11 #include "LDAPException.h"
15 LDAPBindRequest::LDAPBindRequest(const LDAPBindRequest& req) :
17 DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPBindRequest::LDAPBindRequest(&)" << endl);
23 LDAPBindRequest::LDAPBindRequest(const string& dn,const string& passwd,
24 LDAPAsynConnection *connect, const LDAPConstraints *cons,
25 bool isReferral) : LDAPRequest(connect, cons, isReferral){
26 DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPBindRequest::LDAPBindRequest()" << endl);
27 DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " dn:" << dn << endl
28 << " passwd:" << passwd << endl);
34 LDAPBindRequest::~LDAPBindRequest(){
35 DEBUG(LDAP_DEBUG_DESTROY,"LDAPBindRequest::~LDAPBindRequest()" << endl);
38 LDAPMessageQueue* LDAPBindRequest::sendRequest(){
39 DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::sendRequest()" << endl);
42 const char* mech = (m_mech == "" ? 0 : m_mech.c_str());
45 char* tmppwd = (char*) malloc( (m_cred.size()+1) * sizeof(char));
46 m_cred.copy(tmppwd,string::npos);
47 tmppwd[m_cred.size()]=0;
48 tmpcred=ber_bvstr(tmppwd);
50 tmpcred=(BerValue*) malloc(sizeof(BerValue));
58 LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray();
59 LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray();
60 int err=ldap_sasl_bind(m_connection->getSessionHandle(),dn,
61 mech, tmpcred, tmpSrvCtrls, tmpClCtrls, &msgID);
62 LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls);
63 LDAPControlSet::freeLDAPControlArray(tmpClCtrls);
66 if(err != LDAP_SUCCESS){
67 throw LDAPException(err);
70 return new LDAPMessageQueue(this);
74 LDAPRequest* LDAPBindRequest::followReferral(LDAPMsg* /*urls*/){
75 DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::followReferral()" << endl);
76 DEBUG(LDAP_DEBUG_TRACE,
77 "ReferralChasing for bind-operation not implemented yet" << endl);