Back to index

openldap  2.4.31
LDAPSearchResult.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #include <iostream>
00009 
00010 #include "debug.h"
00011 #include "LDAPSearchResult.h"
00012 #include "LDAPRequest.h"
00013 
00014 using namespace std;
00015 
00016 LDAPSearchResult::LDAPSearchResult(const LDAPRequest *req,
00017         LDAPMessage *msg) : LDAPMsg(msg){
00018        DEBUG(LDAP_DEBUG_CONSTRUCT,
00019               "LDAPSearchResult::LDAPSearchResult()" << endl);
00020     entry = new LDAPEntry(req->getConnection(), msg);
00021     //retrieve the controls here
00022     LDAPControl** srvctrls=0;
00023     int err = ldap_get_entry_controls(req->getConnection()->getSessionHandle(),
00024             msg,&srvctrls);
00025     if(err != LDAP_SUCCESS){
00026         ldap_controls_free(srvctrls);
00027     }else{
00028         if (srvctrls){
00029             m_srvControls = LDAPControlSet(srvctrls);
00030             m_hasControls = true;
00031             ldap_controls_free(srvctrls);
00032         }else{
00033             m_hasControls = false;
00034         }
00035     }
00036 }
00037 
00038 LDAPSearchResult::LDAPSearchResult(const LDAPSearchResult& res) :
00039         LDAPMsg(res){
00040     entry = new LDAPEntry(*(res.entry));
00041 }
00042 
00043 LDAPSearchResult::~LDAPSearchResult(){
00044        DEBUG(LDAP_DEBUG_DESTROY,"LDAPSearchResult::~LDAPSearchResult()" << endl);
00045        delete entry;
00046 }
00047 
00048 const LDAPEntry* LDAPSearchResult::getEntry() const{
00049        DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchResult::getEntry()" << endl);
00050        return entry;
00051 }
00052