]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPSaslBindResult.cpp
initial support for SASL
[openldap] / contrib / ldapc++ / src / LDAPSaslBindResult.cpp
1 /*
2  * Copyright 2007, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include "debug.h"
7 #include <lber.h>
8 #include "LDAPRequest.h"
9 #include "LDAPException.h"
10
11 #include "LDAPResult.h"
12 #include "LDAPSaslBindResult.h"
13
14 using namespace std;
15
16 LDAPSaslBindResult::LDAPSaslBindResult(const LDAPRequest* req, LDAPMessage* msg) :
17         LDAPResult(req, msg){
18     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPSaslBindResult::LDAPSaslBindResult()" 
19             << std::endl);
20     BerValue* data = 0;
21     LDAP* lc = req->getConnection()->getSessionHandle();
22     int err = ldap_parse_sasl_bind_result(lc, msg, &data, 0);
23     if( err != LDAP_SUCCESS && err != LDAP_SASL_BIND_IN_PROGRESS ){
24         ber_bvfree(data);
25         throw LDAPException(err);
26     }else{
27         if(data){
28             DEBUG(LDAP_DEBUG_TRACE, "   creds present" << std::endl);
29             m_creds=string(data->bv_val, data->bv_len);
30             ber_bvfree(data);
31         } else {
32             DEBUG(LDAP_DEBUG_TRACE, "   no creds present" << std::endl);
33         }
34     }
35 }
36
37 LDAPSaslBindResult::~LDAPSaslBindResult(){
38     DEBUG(LDAP_DEBUG_DESTROY,"LDAPSaslBindResult::~LDAPSaslBindResult()" << endl);
39 }
40
41 const string& LDAPSaslBindResult::getServerCreds() const{
42     return m_creds;
43 }
44