KLdap

ldapsearch.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 <QObject>
11#include <QString>
12class LdapSearchPrivate;
13
14#include "kldap_core_export.h"
15
16#include "ldapconnection.h"
17#include "ldapcontrol.h"
18#include "ldapobject.h"
19#include "ldapoperation.h"
20#include "ldapserver.h"
21#include "ldapurl.h"
22
23// clazy:excludeall=ctor-missing-parent-argument
24
25namespace KLDAPCore
26{
27/**
28 * @brief
29 * This class starts a search operation on a LDAP server and returns the
30 * search values via a Qt signal.
31 */
32class KLDAP_CORE_EXPORT LdapSearch : public QObject
33{
34 Q_OBJECT
35
36public:
37 /**
38 * Constructs an LdapSearch object
39 */
40 LdapSearch();
41
42 /**
43 * Constructs an LdapConnection object with the given connection. If this
44 * form of constructor used, then always this connection will be used
45 * regardless of the LDAP Url or LdapServer object passed to search().
46 * @param connection the connection used to construct LdapConnection object
47 */
48 explicit LdapSearch(LdapConnection &connection);
49
50 ~LdapSearch() override;
51
52 /**
53 * Sets the connection for this object to use for searches from now
54 * onwards, regardless of the LDAP Url or LdapServer object passed to
55 * search().
56 */
57 void setConnection(LdapConnection &connection);
58
59 /**
60 * Sets the client controls which will sent with each operation.
61 */
62 void setClientControls(const LdapControls &ctrls);
63
64 /**
65 * Sets the server controls which will sent with each operation.
66 */
67 void setServerControls(const LdapControls &ctrls);
68
69 /**
70 * Starts a search operation on the LDAP server @param server,
71 * returning the attributes specified with @param attributes.
72 * @param count means how many entries to list. If it's >0, then result()
73 * will be emitted when the number of entries is reached, but with
74 * isFinished() set to false.
75 */
76 [[nodiscard]] bool search(const LdapServer &server, const QStringList &attributes = QStringList(), int count = 0);
77
78 /**
79 * Starts a search operation on the given LDAP URL.
80 */
81 [[nodiscard]] bool search(const LdapUrl &url, int count = 0);
82
83 /**
84 * Starts a search operation if the LdapConnection object already set
85 * in the constructor.
86 */
87 [[nodiscard]] bool search(const LdapDN &base,
88 LdapUrl::Scope scope = LdapUrl::Sub,
89 const QString &filter = QString(),
90 const QStringList &attributes = QStringList(),
91 int pagesize = 0,
92 int count = 0);
93
94 /**
95 * Continues the search (if you set count to non-zero in search(), and isFinished() is false)
96 */
97 void continueSearch();
98 /**
99 * Returns true if the search is finished else returns false.
100 */
101 [[nodiscard]] bool isFinished();
102 /**
103 * Tries to abandon the search.
104 */
105 void abandon();
106
107 /**
108 * Returns the error code of the search operation (0 if no error).
109 */
110 [[nodiscard]] int error() const;
111
112 /**
113 * Returns the error description of the search operation.
114 */
115 [[nodiscard]] QString errorString() const;
116
117Q_SIGNALS:
118 /**
119 * Emitted for each result object.
120 */
122
123 /**
124 * Emitted when the searching finished.
125 */
127
128private:
129 std::unique_ptr<LdapSearchPrivate> const d;
130 Q_DISABLE_COPY(LdapSearch)
131};
132}
This class represents a connection to an LDAP server.
This class represents an LDAP Object.
Definition ldapobject.h:31
This class starts a search operation on a LDAP server and returns the search values via a Qt signal.
Definition ldapsearch.h:33
void result(KLDAPCore::LdapSearch *search)
Emitted when the searching finished.
void data(KLDAPCore::LdapSearch *search, const KLDAPCore::LdapObject &obj)
Emitted for each result object.
A class that contains LDAP server connection settings.
Definition ldapserver.h:27
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:34 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.