LDAPSaslBindResult.cpp 1.27 KB
Newer Older
Ralf Haferkamp's avatar
Ralf Haferkamp committed
1
// $OpenLDAP$
Ralf Haferkamp's avatar
Ralf Haferkamp committed
2
/*
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
3
 * Copyright 2007-2021 The OpenLDAP Foundation, All Rights Reserved.
Ralf Haferkamp's avatar
Ralf Haferkamp committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#include "debug.h"
#include <lber.h>
#include "LDAPRequest.h"
#include "LDAPException.h"

#include "LDAPResult.h"
#include "LDAPSaslBindResult.h"

using namespace std;

LDAPSaslBindResult::LDAPSaslBindResult(const LDAPRequest* req, LDAPMessage* msg) :
        LDAPResult(req, msg){
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPSaslBindResult::LDAPSaslBindResult()" 
            << std::endl);
    BerValue* data = 0;
    LDAP* lc = req->getConnection()->getSessionHandle();
    int err = ldap_parse_sasl_bind_result(lc, msg, &data, 0);
    if( err != LDAP_SUCCESS && err != LDAP_SASL_BIND_IN_PROGRESS ){
        ber_bvfree(data);
        throw LDAPException(err);
    }else{
        if(data){
            DEBUG(LDAP_DEBUG_TRACE, "   creds present" << std::endl);
            m_creds=string(data->bv_val, data->bv_len);
            ber_bvfree(data);
        } else {
            DEBUG(LDAP_DEBUG_TRACE, "   no creds present" << std::endl);
        }
    }
}

LDAPSaslBindResult::~LDAPSaslBindResult(){
    DEBUG(LDAP_DEBUG_DESTROY,"LDAPSaslBindResult::~LDAPSaslBindResult()" << endl);
}

const string& LDAPSaslBindResult::getServerCreds() const{
    return m_creds;
}