KLDAPCore::LdapOperation Class
This class allows sending an ldap operation (search, rename, modify, delete, compare, exop) to an LDAP server. More...
| Header: | #include <ldapoperation.h> |
| CMake: | find_package(KPim6LdapCore REQUIRED)target_link_libraries(mytarget PRIVATE KPim6::LdapCore) |
Public Functions
| LdapOperation(KLDAPCore::LdapConnection &conn) | |
| ~LdapOperation() | |
| int | abandon(int id) |
| int | add(const KLDAPCore::LdapObject &object) |
| int | add(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops) |
| int | add_s(const KLDAPCore::LdapObject &object) |
| int | add_s(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops) |
| int | bind(const QByteArray &creds = QByteArray(), KLDAPCore::LdapOperation::SASL_Callback_Proc *saslproc = nullptr, void *data = nullptr) |
| int | bind_s(KLDAPCore::LdapOperation::SASL_Callback_Proc *saslproc = nullptr, void *data = nullptr) |
| KLDAPCore::LdapControls | clientControls() const |
| int | compare(const KLDAPCore::LdapDN &dn, const QString &attr, const QByteArray &value) |
| int | compare_s(const KLDAPCore::LdapDN &dn, const QString &attr, const QByteArray &value) |
| KLDAPCore::LdapConnection & | connection() |
| KLDAPCore::LdapControls | controls() const |
| int | del(const KLDAPCore::LdapDN &dn) |
| int | del_s(const KLDAPCore::LdapDN &dn) |
| int | exop(const QString &oid, const QByteArray &data) |
| int | exop_s(const QString &oid, const QByteArray &data) |
| QByteArray | extendedData() const |
| QByteArray | extendedOid() const |
| QString | matchedDn() const |
| int | modify(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops) |
| int | modify_s(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops) |
| KLDAPCore::LdapObject | object() const |
| QList<QByteArray> | referrals() const |
| int | rename(const KLDAPCore::LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold = true) |
| int | rename_s(const KLDAPCore::LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold = true) |
| int | search(const KLDAPCore::LdapDN &base, LdapUrl::Scope scope, const QString &filter, const QStringList &attrs) |
| KLDAPCore::LdapControls | serverControls() const |
| QByteArray | serverCred() const |
| void | setClientControls(const KLDAPCore::LdapControls &ctrls) |
| void | setConnection(KLDAPCore::LdapConnection &conn) |
| void | setServerControls(const KLDAPCore::LdapControls &ctrls) |
| int | waitForResult(int id, int msecs = -1) |
Detailed Description
Member Function Documentation
[explicit] LdapOperation::LdapOperation(KLDAPCore::LdapConnection &conn)
Constructs an LdapOperation with the given LDAP connection. Without a living connection object, LDAP operations are not possible. conn the LDAP connection to use
[noexcept] LdapOperation::~LdapOperation()
Destroys the LdapOperation object.
int LdapOperation::abandon(int id)
Abandons a long-running operation. id the message id of the operation to abandon Returns 0 on success, -1 on error
int LdapOperation::add(const KLDAPCore::LdapObject &object)
Starts an asynchronous add operation. object the LDAP object to add Returns a message id if successful, -1 if not
int LdapOperation::add(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops)
Starts an asynchronous add operation using ModOps. dn the DN to add ops the list of modification operations Returns a message id if successful, -1 if not
int LdapOperation::add_s(const KLDAPCore::LdapObject &object)
Performs a synchronous add operation. object the LDAP object to add to the database Returns KLDAP_SUCCESS if successful, else an LDAP error code
int LdapOperation::add_s(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops)
Performs a synchronous add operation using ModOps. dn the DN to add ops the list of modification operations Returns KLDAP_SUCCESS if successful, else an LDAP error code
int LdapOperation::bind(const QByteArray &creds = QByteArray(), KLDAPCore::LdapOperation::SASL_Callback_Proc *saslproc = nullptr, void *data = nullptr)
Starts an asynchronous bind operation to the server specified in the connection object. Can do simple or SASL bind. Returns a message id if successful, negative value if not. creds optional credentials for the bind saslproc optional SASL callback procedure data optional data for the SASL callback Returns the message ID if successful, negative value if not
int LdapOperation::bind_s(KLDAPCore::LdapOperation::SASL_Callback_Proc *saslproc = nullptr, void *data = nullptr)
Performs a synchronous bind operation to the server. Can do simple or SASL bind. saslproc optional SASL callback procedure data optional data for the SASL callback Returns KLDAP_SUCCESS if successful, else an LDAP error code
KLDAPCore::LdapControls LdapOperation::clientControls() const
Returns the client controls (which were set by setClientControls()). Returns the list of client controls
See also setClientControls().
int LdapOperation::compare(const KLDAPCore::LdapDN &dn, const QString &attr, const QByteArray &value)
Starts an asynchronous compare operation. dn the DN to compare attr the attribute name to compare value the value to compare with Returns a message id if successful, -1 if not
int LdapOperation::compare_s(const KLDAPCore::LdapDN &dn, const QString &attr, const QByteArray &value)
Performs a synchronous compare operation. dn the DN to compare attr the attribute name to compare value the value to compare with Returns KLDAP_COMPARE_TRUE if the entry contains the attribute value, KLDAP_COMPARE_FALSE if it does not, or an LDAP error code
KLDAPCore::LdapConnection &LdapOperation::connection()
Returns the connection object being used. Returns the LDAP connection object
See also setConnection().
KLDAPCore::LdapControls LdapOperation::controls() const
Returns the result object controls from the returned LDAP message. Returns the list of controls
int LdapOperation::del(const KLDAPCore::LdapDN &dn)
Starts an asynchronous delete operation. dn the DN to delete Returns a message id if successful, -1 if not
int LdapOperation::del_s(const KLDAPCore::LdapDN &dn)
Performs a synchronous delete operation. dn the DN to delete Returns KLDAP_SUCCESS if successful, else an LDAP error code
int LdapOperation::exop(const QString &oid, const QByteArray &data)
Starts an asynchronous extended operation. oid the OID of the extended operation data the data for the extended operation Returns a message id if successful, -1 if not
int LdapOperation::exop_s(const QString &oid, const QByteArray &data)
Performs a synchronous extended operation. oid the OID of the extended operation data the data for the extended operation Returns KLDAP_SUCCESS if successful, else an LDAP error code
QByteArray LdapOperation::extendedData() const
Returns the data from the extended operation response. Returns the extended operation data
QByteArray LdapOperation::extendedOid() const
Returns the OID of the extended operation response. Returns the OID of the extended operation
QString LdapOperation::matchedDn() const
Returns the matched DN string from the message. The server might supply this indicating how much of a name in a request was recognized. Returns the matched DN
int LdapOperation::modify(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops)
Starts an asynchronous modify operation. dn the DN to modify ops the list of modification operations Returns a message id if successful, -1 if not
int LdapOperation::modify_s(const KLDAPCore::LdapDN &dn, const KLDAPCore::LdapOperation::ModOps &ops)
Performs a synchronous modify operation. dn the DN to modify ops the list of modification operations Returns KLDAP_SUCCESS if successful, else an LDAP error code
KLDAPCore::LdapObject LdapOperation::object() const
Returns the result object if result() returned RES_SEARCH_ENTRY. Returns the LDAP result object
QList<QByteArray> LdapOperation::referrals() const
Returns the referral strings from the parsed message (if any). Returns the list of referral strings
int LdapOperation::rename(const KLDAPCore::LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold = true)
Starts an asynchronous rename operation (modrdn). dn the DN to rename newRdn the new relative DN newSuperior the new parent DN (empty to keep parent) deleteold whether to delete the old DN Returns a message id if successful, -1 if not
int LdapOperation::rename_s(const KLDAPCore::LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold = true)
Performs a synchronous rename operation (modrdn). dn the DN to rename newRdn the new relative DN newSuperior the new parent DN (empty to keep parent) deleteold whether to delete the old DN Returns KLDAP_SUCCESS if successful, else an LDAP error code
int LdapOperation::search(const KLDAPCore::LdapDN &base, LdapUrl::Scope scope, const QString &filter, const QStringList &attrs)
Starts an asynchronous search operation. base the base DN for the search scope the search scope filter the LDAP filter string attrs the list of attributes to retrieve Returns a message id if successful, -1 if not
KLDAPCore::LdapControls LdapOperation::serverControls() const
Returns the server controls (which were set by setServerControls()). Returns the list of server controls
See also setServerControls().
QByteArray LdapOperation::serverCred() const
Returns the server response for a bind request. (result returned RES_BIND) Returns the server credentials
void LdapOperation::setClientControls(const KLDAPCore::LdapControls &ctrls)
Sets the client controls which will be sent with each operation. ctrls the controls to set
See also clientControls().
void LdapOperation::setConnection(KLDAPCore::LdapConnection &conn)
Sets the connection object to use for LDAP operations. Without a living connection object, LDAP operations are not possible. conn the connection object to set
See also connection().
void LdapOperation::setServerControls(const KLDAPCore::LdapControls &ctrls)
Sets the server controls which will be sent with each operation. ctrls the controls to set
See also serverControls().
int LdapOperation::waitForResult(int id, int msecs = -1)
Waits for a result message from the LDAP server. If msecs is -1, this function will block indefinitely. If msecs is 0, this function will return immediately (poll).
Returns the type of the result LDAP message (RES_XXX constants). -1 if an error occurred, 0 if the timeout value elapsed. Note: Return code -1 means fetching the message resulted in error, not the LDAP operation error. Call connection().ldapErrorCode() to determine if the operation succeeded. id the message id to wait for msecs timeout in milliseconds (-1 for infinite) Returns the result type, 0 on timeout, -1 on error