summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LDAPSearchResult.cpp
blob: f69d0828b0027221130adf4852955dc8e671eb68 (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
// $OpenLDAP$
/*
 * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */


#include <iostream>

#include "debug.h"
#include "LDAPSearchResult.h"
#include "LDAPRequest.h"

using namespace std;

LDAPSearchResult::LDAPSearchResult(const LDAPRequest *req,
        LDAPMessage *msg) : LDAPMsg(msg){
	DEBUG(LDAP_DEBUG_CONSTRUCT,
		"LDAPSearchResult::LDAPSearchResult()" << endl);
    entry = new LDAPEntry(req->getConnection(), msg);
    //retrieve the controls here
    LDAPControl** srvctrls=0;
    int err = ldap_get_entry_controls(req->getConnection()->getSessionHandle(),
            msg,&srvctrls);
    if(err != LDAP_SUCCESS){
        ldap_controls_free(srvctrls);
    }else{
        if (srvctrls){
            m_srvControls = LDAPControlSet(srvctrls);
            m_hasControls = true;
            ldap_controls_free(srvctrls);
        }else{
            m_hasControls = false;
        }
    }
}

LDAPSearchResult::LDAPSearchResult(const LDAPSearchResult& res) :
        LDAPMsg(res){
    entry = new LDAPEntry(*(res.entry));
}

LDAPSearchResult::~LDAPSearchResult(){
	DEBUG(LDAP_DEBUG_DESTROY,"LDAPSearchResult::~LDAPSearchResult()" << endl);
	delete entry;
}

const LDAPEntry* LDAPSearchResult::getEntry() const{
	DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchResult::getEntry()" << endl);
	return entry;
}