3 * Copyright 2000-2017 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <StringList.h>
13 class LDAPUrlException;
15 * This class is used to analyze and store LDAP-Urls as returned by a
16 * LDAP-Server as Referrals and Search References. LDAP-URLs are defined
17 * in RFC1959 and have the following format: <BR>
19 * ldap://host:port/baseDN[?attr[?scope[?filter]]] <BR>
26 * Create a new object from a string that contains a LDAP-Url
27 * @param url The URL String
29 LDAPUrl(const std::string &url="");
37 * @return The part of the URL that is representing the network
43 * Set the port value of the URL
44 * @param dn The port value
46 void setPort(int port);
49 * @return The scope part of the URL is returned.
54 * Set the Scope part of the URL
55 * @param scope The new scope
57 void setScope(const std::string& scope);
60 * @return The complete URL as a string
62 const std::string& getURLString() const;
65 * Set the URL member attribute
66 * @param url The URL String
68 void setURLString(const std::string &url);
71 * @return The hostname or IP-Address of the destination host.
73 const std::string& getHost() const;
76 * Set the Host part of the URL
77 * @param host The new host part
79 void setHost( const std::string &host);
82 * @return The Protocol Scheme of the URL.
84 const std::string& getScheme() const;
87 * Set the Protocol Scheme of the URL
88 * @param host The Protcol scheme. Allowed values are
89 * ldap,ldapi,ldaps and cldap
91 void setScheme( const std::string &scheme );
94 * @return The Base-DN part of the URL
96 const std::string& getDN() const;
99 * Set the DN part of the URL
100 * @param dn The new DN part
102 void setDN( const std::string &dn);
106 * @return The Filter part of the URL
108 const std::string& getFilter() const;
111 * Set the Filter part of the URL
112 * @param filter The new Filter
114 void setFilter( const std::string &filter);
117 * @return The List of attributes that was in the URL
119 const StringList& getAttrs() const;
122 * Set the Attributes part of the URL
123 * @param attrs StringList constaining the List of Attributes
125 void setAttrs( const StringList &attrs);
126 void setExtensions( const StringList &ext);
127 const StringList& getExtensions() const;
130 * Percent-decode a string
131 * @param src The string that is to be decoded
132 * @param dest The decoded result string
134 void percentDecode( const std::string& src, std::string& dest );
137 * Percent-encoded a string
138 * @param src The string that is to be encoded
139 * @param dest The encoded result string
142 std::string& percentEncode( const std::string& src,
148 * Split the url string that is associated with this Object into
149 * it components. The compontens of the URL can be access via the
151 * (this function is mostly for internal use and gets called
152 * automatically whenever necessary)
157 * Generate an URL string from the components that were set with
158 * the various set...() methods
159 * (this function is mostly for internal use and gets called
160 * automatically whenever necessary)
162 void components2Url() const;
164 void string2list(const std::string &src, StringList& sl,
165 bool percentDecode=false);
168 mutable bool regenerate;
173 std::string m_Filter;
175 StringList m_Extensions;
176 mutable std::string m_urlString;
177 std::string m_Scheme;
178 enum mode { base, attrs, scope, filter, extensions };
182 struct code2string_s {
188 class LDAPUrlException {
190 LDAPUrlException(int code, const std::string &msg="" );
193 const std::string getErrorMessage() const;
194 const std::string getAdditionalInfo() const;
196 static const int INVALID_SCHEME = 1;
197 static const int INVALID_PORT = 2;
198 static const int INVALID_SCOPE = 3;
199 static const int INVALID_URL = 4;
200 static const int URL_DECODING_ERROR = 5;
201 static const code2string_s code2string[];
205 std::string m_addMsg;