summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LDAPExtResult.cpp
blob: f3177e82b103ab487a56e74b996577a35775d9ee (plain)
1
2
3
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
46
47
48
49
// $OpenLDAP$
/*
 * Copyright 2000-2022 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

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

#include "LDAPResult.h"
#include "LDAPExtResult.h"

using namespace std;

LDAPExtResult::LDAPExtResult(const LDAPRequest* req, LDAPMessage* msg) :
        LDAPResult(req, msg){
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPExtResult::LDAPExtResult()" << endl);
    char* oid = 0;
    BerValue* data = 0;
    LDAP* lc = req->getConnection()->getSessionHandle();
    int err=ldap_parse_extended_result(lc, msg, &oid, &data, 0);
    if(err != LDAP_SUCCESS){
        ber_bvfree(data);
        ldap_memfree(oid);
        throw LDAPException(err);
    }else{
        m_oid=string(oid);
        ldap_memfree(oid);
        if(data){
            m_data=string(data->bv_val, data->bv_len);
            ber_bvfree(data);
        }
    }
}

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

const string& LDAPExtResult::getResponseOid() const{
    return m_oid;
}

const string& LDAPExtResult::getResponse() const{
    return m_data;
}