Back to index

openldap  2.4.31
LDAPSearchReference.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 "LDAPSearchReference.h"
00012 #include "LDAPException.h"
00013 #include "LDAPRequest.h"
00014 #include "LDAPUrl.h"
00015 
00016 using namespace std;
00017 
00018 LDAPSearchReference::LDAPSearchReference(const LDAPRequest *req,
00019         LDAPMessage *msg) : LDAPMsg(msg){
00020     DEBUG(LDAP_DEBUG_CONSTRUCT,
00021             "LDAPSearchReference::LDAPSearchReference()" << endl;)    
00022     char **ref=0;
00023     LDAPControl** srvctrls=0;
00024     const LDAPAsynConnection* con=req->getConnection();
00025     int err = ldap_parse_reference(con->getSessionHandle(), msg, &ref, 
00026             &srvctrls,0);
00027     if (err != LDAP_SUCCESS){
00028         ber_memvfree((void**) ref);
00029         ldap_controls_free(srvctrls);
00030         throw LDAPException(err);
00031     }else{
00032         m_urlList=LDAPUrlList(ref);
00033         ber_memvfree((void**) ref);
00034         if (srvctrls){
00035             m_srvControls = LDAPControlSet(srvctrls);
00036             m_hasControls = true;
00037             ldap_controls_free(srvctrls);
00038         }else{
00039             m_hasControls = false;
00040         }
00041     }
00042 }
00043 
00044 LDAPSearchReference::~LDAPSearchReference(){
00045     DEBUG(LDAP_DEBUG_DESTROY,"LDAPSearchReference::~LDAPSearchReference()"
00046             << endl);
00047 }
00048 
00049 const LDAPUrlList& LDAPSearchReference::getUrls() const{
00050     DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchReference::getUrls()" << endl);
00051     return m_urlList;
00052 }
00053