]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPUrl.cpp
Entry rwlock is no longer needed as concurrency is managed
[openldap] / contrib / ldapc++ / src / LDAPUrl.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #include "LDAPUrl.h"
8
9 #include <ldap.h>
10 #include "debug.h"
11
12 using namespace std;
13
14 LDAPUrl::LDAPUrl(const char *url){
15     DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPUrl::LDAPUrl()" << endl);
16     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
17             "   url:" << url << endl);
18     if (ldap_is_ldap_url(url)){
19         LDAPURLDesc *urlDesc;
20         ldap_url_parse(url, &urlDesc);
21         if(urlDesc->lud_host){
22             m_Host = string(urlDesc->lud_host);
23         }
24         m_Port = urlDesc->lud_port;
25         if(urlDesc->lud_dn){
26             m_DN = string(urlDesc->lud_dn);
27         }
28         m_Attrs = StringList(urlDesc->lud_attrs);
29         m_Scope = urlDesc->lud_scope;
30         if(urlDesc->lud_filter){
31             m_Filter = string(urlDesc->lud_filter);
32         }else{
33             m_Filter = "";
34         }
35         m_urlString= string(url);
36         ldap_free_urldesc(urlDesc);
37     }else{
38         DEBUG(LDAP_DEBUG_TRACE,"   noUrl:" << url << endl);
39     }
40 }
41
42 LDAPUrl::~LDAPUrl(){
43     DEBUG(LDAP_DEBUG_DESTROY, "LDAPUrl::~LDAPUrl()" << endl);
44     m_Attrs.clear();
45 }
46
47 int LDAPUrl::getPort() const {
48     return m_Port;
49 }
50
51 int LDAPUrl::getScope() const {
52     return m_Scope;
53 }
54
55 const string& LDAPUrl::getURLString() const {
56     return m_urlString;
57 }
58
59 const string& LDAPUrl::getHost() const {
60     return m_Host;
61 }
62
63 const string& LDAPUrl::getDN() const {
64     return m_DN;
65 }
66
67 const string& LDAPUrl::getFilter() const {
68     return m_Filter;
69 }
70
71 const StringList& LDAPUrl::getAttrs() const {
72     return m_Attrs;
73 }
74