1/*
2 This file is part of libkldap.
3 Copyright (c) 2004-2006 Szombathelyi György <gyurco@freemail.hu>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KLDAP_LDAPSERVER_H
22#define KLDAP_LDAPSERVER_H
23
24#include <QtCore/QString>
25
26#include "ldapurl.h"
27#include "ldapdn.h"
28#include "kldap_export.h"
29
30namespace KLDAP {
31
32/**
33 * @short A class that contains LDAP server connection settings.
34 *
35 * This class holds various parameters that are needed to connect
36 * to an LDAP server.
37 */
38class KLDAP_EXPORT LdapServer
39{
40 public:
41 /**
42 * Creates an empty LDAP server object.
43 */
44 LdapServer();
45
46 /**
47 * Creates a new LDAP server object.
48 *
49 * @param url The LDAP url of the server.
50 */
51 LdapServer( const LdapUrl &url );
52
53 /**
54 * Creates a new LDAP server object from an @p other object.
55 */
56 LdapServer( const LdapServer &other );
57
58 /**
59 * Overwrites the values of the LDAP server object with
60 * the values from an @p other object.
61 */
62 LdapServer &operator=( const LdapServer &other );
63
64 /**
65 * Destroys the LDAP server object.
66 */
67 virtual ~LdapServer();
68
69 /**
70 * Describes the encryption settings that can be used
71 * for the LDAP connection.
72 */
73 typedef enum {
74 None, ///< Do not use any encryption.
75 TLS, ///< Use TLS encryption.
76 SSL ///< Use SSL encryption.
77 } Security;
78
79 /**
80 * Describes the authentication method that can be used
81 * for the LDAP connection.
82 */
83 typedef enum {
84 Anonymous, ///< Do no authentication.
85 Simple, ///< Authenticate via login and password.
86 SASL ///< Azthenticate with the SASL framework.
87 } Auth;
88
89 /**
90 * Clears all server settings.
91 */
92 void clear();
93
94 /**
95 * Sets the host of the LDAP connection.
96 */
97 void setHost( const QString &host );
98
99 /**
100 * Returns the host of the LDAP connection.
101 */
102 QString host() const;
103
104 /**
105 * Sets the port of the LDAP connection.
106 * If not port is set, 389 is used as default.
107 * @param port the LDAP port connection to set
108 */
109 void setPort( int port );
110
111 /**
112 * Returns the port of the LDAP connection.
113 */
114 int port() const;
115
116 /**
117 * Sets the @p baseDn of the LDAP connection.
118 */
119 void setBaseDn( const LdapDN &baseDn );
120
121 /**
122 * Returns the baseDn of the LDAP connection.
123 */
124 LdapDN baseDn() const;
125
126 /**
127 * Sets the @p user of the LDAP connection.
128 */
129 void setUser( const QString &user );
130
131 /**
132 * Returns the user of the LDAP connection.
133 */
134 QString user() const;
135
136 /**
137 * Sets the @p bindDn of the LDAP connection.
138 */
139 void setBindDn( const QString &bindDn );
140
141 /**
142 * Returns the bindDn of the LDAP connection.
143 */
144 QString bindDn() const;
145
146 /**
147 * Sets the @p realm of the LDAP connection.
148 */
149 void setRealm( const QString &realm );
150
151 /**
152 * Returns the realm of the LDAP connection.
153 */
154 QString realm() const;
155
156 /**
157 * Sets the @p password of the LDAP connection.
158 */
159 void setPassword( const QString &password );
160
161 /**
162 * Returns the password of the LDAP connection.
163 */
164 QString password() const;
165
166 /**
167 * Sets the protocol @p version of the LDAP connection.
168 * If no version is set, 3 is used as default.
169 * @param version the protocol version to set
170 */
171 void setVersion( int version );
172
173 /**
174 * Returns the protocol version of the LDAP connection.
175 */
176 int version() const;
177
178 /**
179 * Sets the security @p mode of the LDAP connection.
180 * If no security is set, None is used as default.
181 * @param mode the security mode to set
182 */
183 void setSecurity( Security mode );
184
185 /**
186 * Returns the security mode of the LDAP connection.
187 */
188 Security security() const;
189
190 /**
191 * Sets the @p authentication method of the LDAP connection.
192 * If no authentication method is set, Anonymous is used as default.
193 * @param authentication the authentication method to set
194 */
195 void setAuth( Auth authentication );
196
197 /**
198 * Returns the authentication method of the LDAP connection.
199 */
200 Auth auth() const;
201
202 /**
203 * Sets the @p mech of the LDAP connection.
204 */
205 void setMech( const QString &mech );
206
207 /**
208 * Returns the mech of the LDAP connection.
209 */
210 QString mech() const;
211
212 /**
213 * Sets the @p timeout of the LDAP connection.
214 */
215 void setTimeout( int timeout );
216
217 /**
218 * Returns the timeout of the LDAP connection.
219 */
220 int timeout() const;
221
222 /**
223 * Sets the search @p scope of the LDAP connection.
224 */
225 void setScope( LdapUrl::Scope scope );
226
227 /**
228 * Returns the search scope of the LDAP connection.
229 */
230 LdapUrl::Scope scope() const;
231
232 /**
233 * Sets the time @p limit of the LDAP connection.
234 */
235 void setTimeLimit( int limit );
236
237 /**
238 * Returns the time limit of the LDAP connection.
239 */
240 int timeLimit() const;
241
242 /**
243 * Sets the size @p limit of the LDAP connection.
244 */
245 void setSizeLimit( int sizelimit );
246
247 /**
248 * Returns the size limit of the LDAP connection.
249 */
250 int sizeLimit() const;
251
252 /**
253 * Sets the page @p size of the LDAP connection.
254 */
255 void setPageSize( int size );
256
257 /**
258 * Returns the page size of the LDAP connection.
259 */
260 int pageSize() const;
261
262 /**
263 * Sets the @p filter string of the LDAP connection.
264 */
265 void setFilter( const QString &filter );
266
267 /**
268 * Returns the filter string of the LDAP connection.
269 */
270 QString filter() const;
271
272 /**
273 * Sets the server parameters from an RFC2255 compliant LDAP @p url.
274 */
275 void setUrl( const LdapUrl &url );
276
277 /**
278 * Returns the server parameters as an RFC2255 compliant LDAP Url.
279 * The URL extensions which are supported:
280 * Standard: bindname
281 * KLDAP extensions: x-tls, x-version, x-sasl, x-mech, x-realm,
282 * x-sizelimit, x-timelimit, x-pagesize, x-timeout
283 */
284 LdapUrl url() const;
285
286 private:
287 class LdapServerPrivate;
288 LdapServerPrivate *const d;
289};
290
291}
292
293#endif
294