KLdap

ldapconfigwidget.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#include <QWidget>
12
13#include "kldapwidgets_export.h"
14#include "ldapdn.h"
15#include "ldapserver.h"
16#include "ldapurl.h"
17
18namespace KLDAPWidgets
19{
20/**
21 @brief LDAP Configuration widget
22
23 This class can be used to query the user for LDAP connection parameters.
24 It's KConfigXT compatible, using widget names starting with kcfg_
25*/
26
27class KLDAPWIDGETS_EXPORT LdapConfigWidget : public QWidget
28{
30 Q_FLAGS(WinFlags)
31 Q_PROPERTY(WinFlags features READ features WRITE setFeatures)
32 Q_PROPERTY(QString user READ user WRITE setUser)
33 Q_PROPERTY(QString bindDn READ bindDn WRITE setBindDn)
34 Q_PROPERTY(QString realm READ realm WRITE setRealm)
35 Q_PROPERTY(QString password READ password WRITE setPassword)
36 Q_PROPERTY(QString host READ host WRITE setHost)
37 Q_PROPERTY(int port READ port WRITE setPort)
38 Q_PROPERTY(int version READ version WRITE setVersion)
39 Q_PROPERTY(KLDAPCore::LdapDN dn READ dn WRITE setDn)
40 Q_PROPERTY(QString filter READ filter WRITE setFilter)
41 Q_PROPERTY(QString mech READ mech WRITE setMech)
42 Q_PROPERTY(Security security READ security WRITE setSecurity)
43 Q_PROPERTY(Auth auth READ auth WRITE setAuth)
44 Q_PROPERTY(int sizeLimit READ sizeLimit WRITE setSizeLimit)
45 Q_PROPERTY(int timeLimit READ timeLimit WRITE setTimeLimit)
46 Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize)
47
48public:
49 enum WinFlag {
50 W_USER = 0x1,
51 W_BINDDN = 0x2,
52 W_REALM = 0x4,
53 W_PASS = 0x8,
54 W_HOST = 0x10,
55 W_PORT = 0x20,
56 W_VER = 0x40,
57 W_DN = 0x80,
58 W_FILTER = 0x100,
59 W_SECBOX = 0x200,
60 W_AUTHBOX = 0x400,
61 W_TIMELIMIT = 0x800,
62 W_SIZELIMIT = 0x1000,
63 W_PAGESIZE = 0x2000,
64 W_ALL = 0x2fff
65 };
66 Q_DECLARE_FLAGS(WinFlags, WinFlag)
67
68 enum Security {
69 None,
70 SSL,
71 TLS,
72 };
73 Q_ENUM(Security)
74
75 enum Auth {
76 Anonymous,
77 Simple,
78 SASL,
79 };
80 Q_ENUM(Auth)
81
82 /** Constructs an empty configuration widget.
83 * You need to call setFlags() after this.
84 * @param parent the QWidget parent
85 * @param fl the window flags to set
86 */
87 explicit LdapConfigWidget(QWidget *parent = nullptr, Qt::WindowFlags fl = {});
88 /** Constructs a configuration widget */
89 explicit LdapConfigWidget(WinFlags flags, QWidget *parent = nullptr, Qt::WindowFlags fl = {});
90 /** Destructs a configuration widget */
92
93 /** Sets the user name. Kconfig widget name: kcfg_ldapuser
94 * @param user the user name to set
95 */
96 void setUser(const QString &user);
97 /** Gets the user name. Kconfig widget name: kcfg_ldapuser */
98 [[nodiscard]] QString user() const;
99
100 /** Sets the password. Kconfig widget name: kcfg_ldappassword
101 * @param password the password to set
102 */
103 void setPassword(const QString &password);
104 /** Gets the password. Kconfig widget name: kcfg_ldappassword */
105 [[nodiscard]] QString password() const;
106
107 /**
108 * Sets the bind dn.
109 * Kconfig widget name: kcfg_ldapbinddn
110 * @param binddn the LDAP Bind DN to set
111 */
112 void setBindDn(const QString &binddn);
113 /** Gets the bind dn. Kconfig widget name: kcfg_ldapbinddn*/
114 [[nodiscard]] QString bindDn() const;
115
116 /** Sets the SASL realm. Kconfig widget name: kcfg_ldaprealm
117 * @param realm the SASL realm to set
118 */
119 void setRealm(const QString &realm);
120 /** Gets the SASL realm. Kconfig widget name: kcfg_ldaprealm */
121 [[nodiscard]] QString realm() const;
122
123 /** Sets the host name. Kconfig widget name: kcfg_ldaphost
124 * @param host the LDAP host to set
125 */
126 void setHost(const QString &host);
127 /** Gets the host name. Kconfig widget name: kcfg_ldaphost */
128 [[nodiscard]] QString host() const;
129
130 /** Sets the LDAP port. Kconfig widget name: kcfg_ldapport
131 * @param port the LDAP port to set
132 */
133 void setPort(int port);
134 /** Gets the LDAP port. Kconfig widget name: kcfg_ldapport */
135 [[nodiscard]] int port() const;
136
137 /** Sets the LDAP protocol version. Kconfig widget name: kcfg_ldapver
138 * @param version the LDAP protocol version to set
139 */
140 void setVersion(int version);
141 /** Gets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */
142 [[nodiscard]] int version() const;
143
144 /** Sets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn
145 * @param dn the LDAP Base DN to set
146 */
147 void setDn(const KLDAPCore::LdapDN &dn);
148 /** Gets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */
149 [[nodiscard]] KLDAPCore::LdapDN dn() const;
150
151 /** Sets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter
152 * @param filter the LDAP Filter to set
153 */
154 void setFilter(const QString &filter);
155 /** Gets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */
156 [[nodiscard]] QString filter() const;
157
158 /** Sets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech
159 * @param mech the SASL Mechanism to set
160 */
161 void setMech(const QString &mech);
162 /** Gets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */
163 [[nodiscard]] QString mech() const;
164
165 /**
166 * Sets the security type (None, SSL, TLS).
167 * Kconfig widget names: kcfg_ldapnosec, kcfg_ldaptls, kcfg_ldapssl
168 * @param security the security type to set
169 */
170 void setSecurity(Security security);
171 /**
172 * Returns the security type.
173 * Kconfig widget names: kcfg_ldapnosec, kcfg_ldaptls, kcfg_ldapssl
174 * @param security the security type to set
175 */
176 [[nodiscard]] Security security() const;
177
178 /**
179 * Sets the authentication type (Anonymous, Simple, SASL).
180 * Kconfig widget names: kcfg_ldapanon, kcfg_ldapsimple, kcfg_ldapsasl
181 * @param auth the authentication type to set
182 */
183 void setAuth(Auth auth);
184 /**
185 * Returns the authentication type.
186 * Kconfig widget names: kcfg_ldapanon, kcfg_ldapsimple, kcfg_ldapsasl
187 * @param auth the authentication type to set
188 */
189 [[nodiscard]] Auth auth() const;
190
191 /**
192 * Sets the size limit.
193 * KConfig widget name: kcfg_ldapsizelimit
194 * @param sizelimit the size limit to set
195 */
196 void setSizeLimit(int sizelimit);
197 /**
198 * Returns the size limit.
199 * KConfig widget name: kcfg_ldapsizelimit
200 */
201 [[nodiscard]] int sizeLimit() const;
202
203 /**
204 * Sets the time limit.
205 * KConfig widget name: kcfg_ldaptimelimit
206 * @param timelimit the time limit to set
207 */
208 void setTimeLimit(int timelimit);
209 /**
210 * Returns the time limit.
211 * KConfig widget name: kcfg_ldaptimelimit
212 */
213 [[nodiscard]] int timeLimit() const;
214
215 /**
216 * Sets the page size.
217 * KConfig widget name: kcfg_ldappagesize
218 * @param pagesize the page size to set
219 */
220 void setPageSize(int pagesize);
221 /**
222 * Returns the page size.
223 * KConfig widget name: kcfg_ldappagesize
224 */
225 [[nodiscard]] int pageSize() const;
226
227 [[nodiscard]] WinFlags features() const;
228 void setFeatures(WinFlags features);
229
230 /**
231 * Returns a LDAP Url constructed from the settings given.
232 * Extensions are filled for use in the LDAP KIO worker.
233 */
234 [[nodiscard]] KLDAPCore::LdapUrl url() const;
235 /**
236 * Set up the widget via an LDAP Url.
237 * @param url the LDAP Url to set
238 */
239 void setUrl(const KLDAPCore::LdapUrl &url);
240
241 /**
242 * Returns an LdapServer object constructed from the settings given.
243 */
244 [[nodiscard]] KLDAPCore::LdapServer server() const;
245 /**
246 * Set up the widget via an LdapServer object.
247 * @param server the LdapServer object to set
248 */
250
252 /**
253 * @since 4.13
254 */
256
257private:
258 class LdapConfigWidgetPrivate;
259 std::unique_ptr<LdapConfigWidgetPrivate> const d;
260};
261
262Q_DECLARE_OPERATORS_FOR_FLAGS(KLDAPWidgets::LdapConfigWidget::WinFlags)
263}
A class that contains LDAP server connection settings.
Definition ldapserver.h:27
A special url class for LDAP.
Definition ldapurl.h:30
void setPassword(const QString &password)
Sets the password.
void hostNameChanged(const QString &)
void setSizeLimit(int sizelimit)
Sets the size limit.
void setMech(const QString &mech)
Sets the SASL Mechanism.
void setHost(const QString &host)
Sets the host name.
void setRealm(const QString &realm)
Sets the SASL realm.
void setVersion(int version)
Sets the LDAP protocol version.
void setUrl(const KLDAPCore::LdapUrl &url)
Set up the widget via an LDAP Url.
void setDn(const KLDAPCore::LdapDN &dn)
Sets the LDAP Base DN.
void setSecurity(Security security)
Sets the security type (None, SSL, TLS).
~LdapConfigWidget() override
Destructs a configuration widget.
KLDAPCore::LdapServer server() const
Returns an LdapServer object constructed from the settings given.
KLDAPCore::LdapUrl url() const
Returns a LDAP Url constructed from the settings given.
void setPageSize(int pagesize)
Sets the page size.
LdapConfigWidget(QWidget *parent=nullptr, Qt::WindowFlags fl={})
Constructs an empty configuration widget.
void setBindDn(const QString &binddn)
Sets the bind dn.
void setPort(int port)
Sets the LDAP port.
void setTimeLimit(int timelimit)
Sets the time limit.
void setAuth(Auth auth)
Sets the authentication type (Anonymous, Simple, SASL).
void setUser(const QString &user)
Sets the user name.
void setServer(const KLDAPCore::LdapServer &server)
Set up the widget via an LdapServer object.
void setFilter(const QString &filter)
Sets the LDAP Filter.
Q_SCRIPTABLE bool setFilter(const QString &filter)
Q_FLAGS(...)
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
typedef WindowFlags
QWidget(QWidget *parent, Qt::WindowFlags f)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:52:20 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.