KLdap

ldapserver.h
1/*
2 This file is part of libkldap.
3 SPDX-FileCopyrightText: 2004-2006 Szombathelyi György <gyurco@freemail.hu>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <QString>
11
12#include "kldap_core_export.h"
13#include "ldapdn.h"
14#include "ldapurl.h"
15
16// clazy:excludeall=copyable-polymorphic
17
18namespace KLDAPCore
19{
20/**
21 * @short A class that contains LDAP server connection settings.
22 *
23 * This class holds various parameters that are needed to connect
24 * to an LDAP server.
25 */
26class KLDAP_CORE_EXPORT LdapServer
27{
28public:
29 /**
30 * Creates an empty LDAP server object.
31 */
32 LdapServer();
33
34 /**
35 * Creates a new LDAP server object.
36 *
37 * @param url The LDAP url of the server.
38 */
39 explicit LdapServer(const LdapUrl &url);
40
41 /**
42 * Creates a new LDAP server object from an @p other object.
43 */
44 LdapServer(const LdapServer &other);
45
46 /**
47 * Overwrites the values of the LDAP server object with
48 * the values from an @p other object.
49 */
50 LdapServer &operator=(const LdapServer &other);
51
52 /**
53 * Destroys the LDAP server object.
54 */
56
57 /**
58 * Describes the encryption settings that can be used
59 * for the LDAP connection.
60 */
61 using Security = enum {
62 None, ///< Do not use any encryption.
63 TLS, ///< Use TLS encryption.
64 SSL ///< Use SSL encryption.
65 };
66
67 /**
68 * Describes the authentication method that can be used
69 * for the LDAP connection.
70 */
71 using Auth = enum {
72 Anonymous, ///< Do no authentication.
73 Simple, ///< Authenticate via login and password.
74 SASL ///< Azthenticate with the SASL framework.
75 };
76
77 /**
78 * Describes the certificate request and check behaviour
79 * for TLS/SSL connections.
80 */
81 using TLSRequireCertificate = enum {
82 TLSReqCertDefault, ///< Use system defaults
83 TLSReqCertNever, ///< Do not require any certificates.
84 TLSReqCertDemand, ///< Use LDAP_OPT_X_TLS_DEMAND.
85 TLSReqCertAllow, ///< Use LDAP_OPT_X_TLS_ALLOW.
86 TLSReqCertTry, ///< Use LDAP_OPT_X_TLS_TRY.
87 TLSReqCertHard, ///< Use LDAP_OPT_X_TLS_HARD.
88 };
89
90 /**
91 * Clears all server settings.
92 */
93 void clear();
94
95 /**
96 * Sets the host of the LDAP connection.
97 */
98 void setHost(const QString &host);
99
100 /**
101 * Returns the host of the LDAP connection.
102 */
103 [[nodiscard]] QString host() const;
104
105 /**
106 * Sets the port of the LDAP connection.
107 * If not port is set, 389 is used as default.
108 * @param port the LDAP port connection to set
109 */
110 void setPort(int port);
111
112 /**
113 * Returns the port of the LDAP connection.
114 */
115 [[nodiscard]] int port() const;
116
117 /**
118 * Sets the @p baseDn of the LDAP connection.
119 */
120 void setBaseDn(const LdapDN &baseDn);
121
122 /**
123 * Returns the baseDn of the LDAP connection.
124 */
125 [[nodiscard]] LdapDN baseDn() const;
126
127 /**
128 * Sets the @p user of the LDAP connection.
129 */
130 void setUser(const QString &user);
131
132 /**
133 * Returns the user of the LDAP connection.
134 */
135 [[nodiscard]] QString user() const;
136
137 /**
138 * Sets the @p bindDn of the LDAP connection.
139 */
140 void setBindDn(const QString &bindDn);
141
142 /**
143 * Returns the bindDn of the LDAP connection.
144 */
145 [[nodiscard]] QString bindDn() const;
146
147 /**
148 * Sets the @p realm of the LDAP connection.
149 */
150 void setRealm(const QString &realm);
151
152 /**
153 * Returns the realm of the LDAP connection.
154 */
155 [[nodiscard]] QString realm() const;
156
157 /**
158 * Sets the @p password of the LDAP connection.
159 */
160 void setPassword(const QString &password);
161
162 /**
163 * Returns the password of the LDAP connection.
164 */
165 [[nodiscard]] QString password() const;
166
167 /**
168 * Sets the protocol @p version of the LDAP connection.
169 * If no version is set, 3 is used as default.
170 * @param version the protocol version to set
171 */
172 void setVersion(int version);
173
174 /**
175 * Returns the protocol version of the LDAP connection.
176 */
177 [[nodiscard]] int version() const;
178
179 /**
180 * Sets the security @p mode of the LDAP connection.
181 * If no security is set, None is used as default.
182 * @param mode the security mode to set
183 */
184 void setSecurity(Security mode);
185
186 /**
187 * Returns the security mode of the LDAP connection.
188 */
189 [[nodiscard]] Security security() const;
190
191 /**
192 * Sets the @p authentication method of the LDAP connection.
193 * If no authentication method is set, Anonymous is used as default.
194 * @param authentication the authentication method to set
195 */
196 void setAuth(Auth authentication);
197
198 /**
199 * Returns the authentication method of the LDAP connection.
200 */
201 [[nodiscard]] Auth auth() const;
202
203 /**
204 * Sets the certificate require mode for TLS/SSL connections
205 */
206 void setTLSRequireCertificate(TLSRequireCertificate reqCert);
207
208 /**
209 * Returns the certificate require mode for TLS/SSL connections
210 */
211 [[nodiscard]] TLSRequireCertificate tlsRequireCertificate() const;
212
213 /**
214 * Sets the CA certificate file for TLS/SSL connections
215 */
216 void setTLSCACertFile(const QString &caCertFile);
217
218 /**
219 * Returns the CA certificate file used for TLS/SSL connections.
220 */
221 [[nodiscard]] QString tlsCACertFile() const;
222
223 /**
224 * Sets the @p mech of the LDAP connection.
225 */
226 void setMech(const QString &mech);
227
228 /**
229 * Returns the mech of the LDAP connection.
230 */
231 [[nodiscard]] QString mech() const;
232
233 /**
234 * Sets the @p timeout of the LDAP connection.
235 */
236 void setTimeout(int timeout);
237
238 /**
239 * Returns the timeout of the LDAP connection.
240 */
241 [[nodiscard]] int timeout() const;
242
243 /**
244 * Sets the search @p scope of the LDAP connection.
245 */
246 void setScope(LdapUrl::Scope scope);
247
248 /**
249 * Returns the search scope of the LDAP connection.
250 */
251 [[nodiscard]] LdapUrl::Scope scope() const;
252
253 /**
254 * Sets the time @p limit of the LDAP connection.
255 */
256 void setTimeLimit(int limit);
257
258 /**
259 * Returns the time limit of the LDAP connection.
260 */
261 [[nodiscard]] int timeLimit() const;
262
263 /**
264 * Sets the size @p limit of the LDAP connection.
265 */
266 void setSizeLimit(int sizelimit);
267
268 /**
269 * Returns the size limit of the LDAP connection.
270 */
271 [[nodiscard]] int sizeLimit() const;
272
273 /**
274 * Sets the page @p size of the LDAP connection.
275 */
276 void setPageSize(int size);
277
278 /**
279 * Returns the page size of the LDAP connection.
280 */
281 [[nodiscard]] int pageSize() const;
282
283 /**
284 * Sets the @p filter string of the LDAP connection.
285 */
286 void setFilter(const QString &filter);
287
288 /**
289 * Returns the filter string of the LDAP connection.
290 */
291 [[nodiscard]] QString filter() const;
292
293 /**
294 * Sets the server parameters from an RFC2255 compliant LDAP @p url.
295 */
296 void setUrl(const LdapUrl &url);
297
298 /**
299 * Returns the server parameters as an RFC2255 compliant LDAP Url.
300 * The URL extensions which are supported:
301 * Standard: bindname
302 * KLDAP extensions: x-tls, x-version, x-sasl, x-mech, x-realm,
303 * x-sizelimit, x-timelimit, x-pagesize, x-timeout
304 */
305 [[nodiscard]] LdapUrl url() const;
306
307 void setCompletionWeight(int value);
308 [[nodiscard]] int completionWeight() const;
309
310 void setActivities(const QStringList &lst);
311 [[nodiscard]] QStringList activities() const;
312
313 void setEnablePlasmaActivities(bool enabled);
314 [[nodiscard]] bool enablePlasmaActivities() const;
315
316private:
317 class LdapServerPrivate;
318 std::unique_ptr<LdapServerPrivate> const d;
319};
320}
321KLDAP_CORE_EXPORT QDebug operator<<(QDebug d, const KLDAPCore::LdapServer &t);
A class that contains LDAP server connection settings.
Definition ldapserver.h:27
enum { None, TLS, SSL } Security
Describes the encryption settings that can be used for the LDAP connection.
Definition ldapserver.h:61
enum { TLSReqCertDefault, TLSReqCertNever, TLSReqCertDemand, TLSReqCertAllow, TLSReqCertTry, TLSReqCertHard, } TLSRequireCertificate
Describes the certificate request and check behaviour for TLS/SSL connections.
Definition ldapserver.h:81
enum { Anonymous, Simple, SASL } Auth
Describes the authentication method that can be used for the LDAP connection.
Definition ldapserver.h:71
~LdapServer()
Destroys the LDAP server object.
A special url class for LDAP.
Definition ldapurl.h:30
enum { Base, One, Sub } Scope
Describes the scope of the LDAP url.
Definition ldapurl.h:44
Q_SCRIPTABLE bool setFilter(const QString &filter)
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.