summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LDAPSearchReference.cpp
blob: 20055106ef59a4f9635021b995f201b808b3a752 (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
50
51
52
53
// $OpenLDAP$
/*
 * Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */


#include <iostream>

#include "debug.h"
#include "LDAPSearchReference.h"
#include "LDAPException.h"
#include "LDAPRequest.h"
#include "LDAPUrl.h"

using namespace std;

LDAPSearchReference::LDAPSearchReference(const LDAPRequest *req,
        LDAPMessage *msg) : LDAPMsg(msg){
    DEBUG(LDAP_DEBUG_CONSTRUCT,
            "LDAPSearchReference::LDAPSearchReference()" << endl;)    
    char **ref=0;
    LDAPControl** srvctrls=0;
    const LDAPAsynConnection* con=req->getConnection();
    int err = ldap_parse_reference(con->getSessionHandle(), msg, &ref, 
            &srvctrls,0);
    if (err != LDAP_SUCCESS){
        ber_memvfree((void**) ref);
        ldap_controls_free(srvctrls);
        throw LDAPException(err);
    }else{
        m_urlList=LDAPUrlList(ref);
        ber_memvfree((void**) ref);
        if (srvctrls){
            m_srvControls = LDAPControlSet(srvctrls);
            m_hasControls = true;
            ldap_controls_free(srvctrls);
        }else{
            m_hasControls = false;
        }
    }
}

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

const LDAPUrlList& LDAPSearchReference::getUrls() const{
    DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchReference::getUrls()" << endl);
    return m_urlList;
}