13070Spst// OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPSearchReference.cpp,v 1.4.2.1 2008/04/14 23:09:26 quanah Exp
23070Spst/*
33070Spst * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
43070Spst * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
53070Spst */
63070Spst
73070Spst
83070Spst#include <iostream>
93070Spst
103070Spst#include "debug.h"
113070Spst#include "LDAPSearchReference.h"
123070Spst#include "LDAPException.h"
133070Spst#include "LDAPRequest.h"
143070Spst#include "LDAPUrl.h"
153070Spst
163070Spstusing namespace std;
173070Spst
183070SpstLDAPSearchReference::LDAPSearchReference(const LDAPRequest *req,
193070Spst        LDAPMessage *msg) : LDAPMsg(msg){
203070Spst    DEBUG(LDAP_DEBUG_CONSTRUCT,
213070Spst            "LDAPSearchReference::LDAPSearchReference()" << endl;)
223070Spst    char **ref=0;
233070Spst    LDAPControl** srvctrls=0;
243070Spst    const LDAPAsynConnection* con=req->getConnection();
253070Spst    int err = ldap_parse_reference(con->getSessionHandle(), msg, &ref,
2692986Sobrien            &srvctrls,0);
2792986Sobrien    if (err != LDAP_SUCCESS){
283070Spst        ber_memvfree((void**) ref);
293070Spst        ldap_controls_free(srvctrls);
303070Spst        throw LDAPException(err);
313070Spst    }else{
323070Spst        m_urlList=LDAPUrlList(ref);
3343171Sgallatin        ber_memvfree((void**) ref);
343070Spst        if (srvctrls){
353070Spst            m_srvControls = LDAPControlSet(srvctrls);
3617141Sjkh            m_hasControls = true;
373070Spst            ldap_controls_free(srvctrls);
383070Spst        }else{
393070Spst            m_hasControls = false;
4065532Snectar        }
4165532Snectar    }
42145721Sume}
4314639Swpaul
4414639SwpaulLDAPSearchReference::~LDAPSearchReference(){
4514639Swpaul    DEBUG(LDAP_DEBUG_DESTROY,"LDAPSearchReference::~LDAPSearchReference()"
4614639Swpaul            << endl);
4714639Swpaul}
48145633Sume
493070Spstconst LDAPUrlList& LDAPSearchReference::getUrls() const{
503070Spst    DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchReference::getUrls()" << endl);
51145633Sume    return m_urlList;
52145633Sume}
53145728Sume
543070Spst