KLDAPCore::LdapOperation

Search for usage in LXR

KLDAPCore::LdapOperation Class Reference

#include <ldapoperation.h>

Public Types

using ModOp
 
using ModOps = QList<ModOp>
 
using ModType
 
using ResultType
 
using SASL_Callback_Proc = int(SASL_Credentials &, void *)
 
enum  SASL_Fields { SASL_Authname = 0x1 , SASL_Authzid = 0x2 , SASL_Realm = 0x4 , SASL_Password = 0x8 }
 

Public Member Functions

 LdapOperation (LdapConnection &conn)
 
int abandon (int id)
 
int add (const LdapDN &dn, const ModOps &ops)
 
int add (const LdapObject &object)
 
int add_s (const LdapDN &dn, const ModOps &ops)
 
int add_s (const LdapObject &object)
 
int bind (const QByteArray &creds=QByteArray(), SASL_Callback_Proc *saslproc=nullptr, void *data=nullptr)
 
int bind_s (SASL_Callback_Proc *saslproc=nullptr, void *data=nullptr)
 
LdapControls clientControls () const
 
int compare (const LdapDN &dn, const QString &attr, const QByteArray &value)
 
int compare_s (const LdapDN &dn, const QString &attr, const QByteArray &value)
 
LdapConnectionconnection ()
 
LdapControls controls () const
 
int del (const LdapDN &dn)
 
int del_s (const 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 LdapDN &dn, const ModOps &ops)
 
int modify_s (const LdapDN &dn, const ModOps &ops)
 
LdapObject object () const
 
QList< QByteArrayreferrals () const
 
int rename (const LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold=true)
 
int rename_s (const LdapDN &dn, const QString &newRdn, const QString &newSuperior, bool deleteold=true)
 
int search (const LdapDN &base, LdapUrl::Scope scope, const QString &filter, const QStringList &attrs)
 
LdapControls serverControls () const
 
QByteArray serverCred () const
 
void setClientControls (const LdapControls &ctrls)
 
void setConnection (LdapConnection &conn)
 
void setServerControls (const LdapControls &ctrls)
 
int waitForResult (int id, int msecs=-1)
 

Detailed Description

This class allows sending an ldap operation (search, rename, modify, delete, compare, exop) to an LDAP server.

Definition at line 30 of file ldapoperation.h.

Member Typedef Documentation

◆ ModOp

using KLDAPCore::LdapOperation::ModOp
Initial value:
struct {
ModType type;
QString attr;
}

Definition at line 54 of file ldapoperation.h.

◆ ModOps

Definition at line 60 of file ldapoperation.h.

◆ ModType

using KLDAPCore::LdapOperation::ModType
Initial value:
enum {
Mod_None,
Mod_Add,
Mod_Replace,
Mod_Del,
}

Definition at line 33 of file ldapoperation.h.

◆ ResultType

using KLDAPCore::LdapOperation::ResultType
Initial value:
enum {
RES_BIND = 0x61,
RES_SEARCH_ENTRY = 0x64,
RES_SEARCH_REFERENCE = 0x73,
RES_SEARCH_RESULT = 0x65,
RES_MODIFY = 0x67,
RES_ADD = 0x69,
RES_DELETE = 0x69,
RES_MODDN = 0x6d,
RES_COMPARE = 0x6f,
RES_EXTENDED = 0x78,
RES_EXTENDED_PARTIAL = 0x79,
}

Definition at line 40 of file ldapoperation.h.

◆ SASL_Callback_Proc

using KLDAPCore::LdapOperation::SASL_Callback_Proc = int(SASL_Credentials &, void *)

Definition at line 77 of file ldapoperation.h.

Member Enumeration Documentation

◆ SASL_Fields

enum KLDAPCore::LdapOperation::SASL_Fields

Definition at line 62 of file ldapoperation.h.

Constructor & Destructor Documentation

◆ LdapOperation() [1/2]

LdapOperation::LdapOperation ( )

Definition at line 76 of file ldapoperation.cpp.

◆ LdapOperation() [2/2]

LdapOperation::LdapOperation ( LdapConnection & conn)
explicit

Definition at line 82 of file ldapoperation.cpp.

Member Function Documentation

◆ abandon()

int LdapOperation::abandon ( int id)
nodiscard

Abandons a long-running operation.

Requires the message id.

Definition at line 1273 of file ldapoperation.cpp.

◆ add() [1/2]

int LdapOperation::add ( const LdapDN & dn,
const ModOps & ops )
nodiscard

Starts an addition operation.

This version accepts ModOps not LdapObject. Returns a message id if successful, -1 if not.

Parameters
dnthe LdapDN operation to start
opsthe ModOps operation to start

Definition at line 1195 of file ldapoperation.cpp.

◆ add() [2/2]

int LdapOperation::add ( const LdapObject & object)
nodiscard

Starts an addition operation.

Returns a message id if successful, -1 if not.

Parameters
objectthe additional operation to start

Definition at line 1183 of file ldapoperation.cpp.

◆ add_s() [1/2]

int LdapOperation::add_s ( const LdapDN & dn,
const ModOps & ops )
nodiscard

Adds the specified object to the LDAP database.

This version accepts ModOps not LdapObject. This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Parameters
dnthe LdapDN object to add
opsthe ModOps object to add

Definition at line 1201 of file ldapoperation.cpp.

◆ add_s() [2/2]

int LdapOperation::add_s ( const LdapObject & object)
nodiscard

Adds the specified object to the LDAP database.

Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Parameters
objectthe object to add to LDAP database

Definition at line 1189 of file ldapoperation.cpp.

◆ bind()

int LdapOperation::bind ( const QByteArray & creds = QByteArray(),
SASL_Callback_Proc * saslproc = nullptr,
void * data = nullptr )
nodiscard

Binds to the server which specified in the connection object.

Can do simple or SASL bind. Returns a message id if successful, negative value if not.

Definition at line 1165 of file ldapoperation.cpp.

◆ bind_s()

int LdapOperation::bind_s ( SASL_Callback_Proc * saslproc = nullptr,
void * data = nullptr )
nodiscard

Binds to the server which specified in the connection object.

Can do simple or SASL bind. This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Definition at line 1171 of file ldapoperation.cpp.

◆ clientControls()

LdapControls LdapOperation::clientControls ( ) const
nodiscard

Returns the client controls (which set by setClientControls()).

Definition at line 110 of file ldapoperation.cpp.

◆ compare()

int LdapOperation::compare ( const LdapDN & dn,
const QString & attr,
const QByteArray & value )
nodiscard

Starts a compare operation on the given DN, compares the specified attribute with the given value.

Returns a message id if successful, -1 if not.

Definition at line 1243 of file ldapoperation.cpp.

◆ compare_s()

int LdapOperation::compare_s ( const LdapDN & dn,
const QString & attr,
const QByteArray & value )
nodiscard

Performs a compare operation on the given DN, compares the specified attribute with the given value.

This is the synchronous version. Returns KLDAP_COMPARE_TRUE if the entry contains the attribute value and KLDAP_COMPARE_FALSE if it does not. Otherwise, some error code is returned.

Definition at line 1255 of file ldapoperation.cpp.

◆ connection()

LdapConnection & LdapOperation::connection ( )

Returns the connection object.

Definition at line 95 of file ldapoperation.cpp.

◆ controls()

LdapControls LdapOperation::controls ( ) const
nodiscard

Returns the server controls from the returned ldap message (grabbed by result()).

Definition at line 125 of file ldapoperation.cpp.

◆ del()

int LdapOperation::del ( const LdapDN & dn)
nodiscard

Starts a delete operation on the given DN.

Returns a message id if successful, -1 if not.

Definition at line 1219 of file ldapoperation.cpp.

◆ del_s()

int LdapOperation::del_s ( const LdapDN & dn)
nodiscard

Deletes the given DN.

This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Parameters
dnthe dn to delete

Definition at line 1225 of file ldapoperation.cpp.

◆ exop()

int LdapOperation::exop ( const QString & oid,
const QByteArray & data )
nodiscard

Starts an extended operation specified with oid and data.

Returns a message id if successful, -1 if not.

Definition at line 1249 of file ldapoperation.cpp.

◆ exop_s()

int LdapOperation::exop_s ( const QString & oid,
const QByteArray & data )
nodiscard

Performs an extended operation specified with oid and data.

This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Definition at line 1261 of file ldapoperation.cpp.

◆ extendedData()

QByteArray LdapOperation::extendedData ( ) const
nodiscard

Returns the data from the extended operation response (result returned RES_EXTENDED).

Definition at line 135 of file ldapoperation.cpp.

◆ extendedOid()

QByteArray LdapOperation::extendedOid ( ) const
nodiscard

Returns the OID of the extended operation response (result returned RES_EXTENDED).

Definition at line 130 of file ldapoperation.cpp.

◆ matchedDn()

QString LdapOperation::matchedDn ( ) const
nodiscard

The server might supply a matched DN string in the message indicating how much of a name in a request was recognized.

This can be grabbed by matchedDn().

Definition at line 140 of file ldapoperation.cpp.

◆ modify()

int LdapOperation::modify ( const LdapDN & dn,
const ModOps & ops )
nodiscard

Starts a modify operation on the given DN.

Returns a message id if successful, -1 if not.

Parameters
dnthe DN to start modify operation on

Definition at line 1231 of file ldapoperation.cpp.

◆ modify_s()

int LdapOperation::modify_s ( const LdapDN & dn,
const ModOps & ops )
nodiscard

Performs a modify operation on the given DN.

This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Definition at line 1237 of file ldapoperation.cpp.

◆ object()

LdapObject LdapOperation::object ( ) const
nodiscard

Returns the result object if result() returned RES_SEARCH_ENTRY.

Definition at line 120 of file ldapoperation.cpp.

◆ referrals()

QList< QByteArray > LdapOperation::referrals ( ) const
nodiscard

This function returns the referral strings from the parsed message (if any).

Definition at line 145 of file ldapoperation.cpp.

◆ rename()

int LdapOperation::rename ( const LdapDN & dn,
const QString & newRdn,
const QString & newSuperior,
bool deleteold = true )
nodiscard

Starts a modrdn operation on given DN, changing its RDN to newRdn, changing its parent to newSuperior (if it's not empty), and deletes the old dn if deleteold is true.

Returns a message id if successful, -1 if not.

Definition at line 1207 of file ldapoperation.cpp.

◆ rename_s()

int LdapOperation::rename_s ( const LdapDN & dn,
const QString & newRdn,
const QString & newSuperior,
bool deleteold = true )
nodiscard

Performs a modrdn operation on given DN, changing its RDN to newRdn, changing its parent to newSuperior (if it's not empty), and deletes the old dn if deleteold is true.

This is the synchronous version. Returns KLDAP_SUCCESS id if successful, else an LDAP error code.

Definition at line 1213 of file ldapoperation.cpp.

◆ search()

int LdapOperation::search ( const LdapDN & base,
LdapUrl::Scope scope,
const QString & filter,
const QStringList & attrs )
nodiscard

Starts a search operation with the given base DN, scope, filter and result attributes.

Returns a message id if successful, -1 if not.

Definition at line 1177 of file ldapoperation.cpp.

◆ serverControls()

LdapControls LdapOperation::serverControls ( ) const
nodiscard

Returns the server controls (which set by setServerControls()).

Definition at line 115 of file ldapoperation.cpp.

◆ serverCred()

QByteArray LdapOperation::serverCred ( ) const
nodiscard

Returns the server response for a bind request (result returned RES_BIND).

Definition at line 150 of file ldapoperation.cpp.

◆ setClientControls()

void LdapOperation::setClientControls ( const LdapControls & ctrls)

Sets the client controls which will sent with each operation.

Definition at line 100 of file ldapoperation.cpp.

◆ setConnection()

void LdapOperation::setConnection ( LdapConnection & conn)

Sets the connection object.

Without living connection object, LDAP operations are not possible.

Parameters
theconnection object to set

Definition at line 90 of file ldapoperation.cpp.

◆ setServerControls()

void LdapOperation::setServerControls ( const LdapControls & ctrls)

Sets the server controls which will sent with each operation.

Definition at line 105 of file ldapoperation.cpp.

◆ waitForResult()

int LdapOperation::waitForResult ( int id,
int msecs = -1 )
nodiscard

Waits for up to msecs milliseconds for a result message from the LDAP server.

If msecs is -1, then this function will block indefinitely. If msecs is 0, then this function will return immediately, that is it will perform a poll for a result message.

Returns the type of the result LDAP message (RES_XXX constants). -1 if error occurred, 0 if the timeout value elapsed. Note! Return code -1 means that fetching the message resulted in error, not the LDAP operation error. Call connection().ldapErrorCode() to determine if the operation succeeded.

Definition at line 1267 of file ldapoperation.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.