]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPSearchReference.cpp
Initial check of the LDAP C++ SDK written by Ralf Haferkamp <rhafer@suse.de>
[openldap] / contrib / ldapc++ / src / LDAPSearchReference.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 // $Id: LDAPSearchReference.cpp,v 1.7 2000/08/31 17:43:49 rhafer Exp $
7
8 #include <iostream>
9
10 #include "debug.h"
11 #include "LDAPSearchReference.h"
12 #include "LDAPException.h"
13 #include "LDAPRequest.h"
14 #include "LDAPUrl.h"
15
16 LDAPSearchReference::LDAPSearchReference(LDAPRequest *req, LDAPMessage *msg) : 
17         LDAPMsg(msg){
18     DEBUG(LDAP_DEBUG_TRACE,"LDAPSearchReference::LDAPSearchReference()"
19             << endl;)    
20     char **ref=0;
21     const LDAPAsynConnection* con=req->getConnection();
22     int err = ldap_parse_reference(con->getSessionHandle(), msg, &ref, 0,0);
23     if (err != LDAP_SUCCESS){
24         throw LDAPException(err);
25     }else{
26         char **tmp;
27         for (tmp=ref; *tmp != 0; tmp++){   
28             m_urlList.push_back( new LDAPUrl(*tmp) );
29             DEBUG(LDAP_DEBUG_PARAMETER,"   URL:" << *tmp << endl);
30         }
31     }
32 }
33
34 LDAPSearchReference::~LDAPSearchReference(){
35     LDAPUrlList::const_iterator i;
36     for(i=m_urlList.begin(); i!=m_urlList.end(); i++){
37         delete *i;
38     }
39 }
40
41 LDAPUrlList* LDAPSearchReference::getURLs(){
42     return &m_urlList;
43 }
44