KLDAP Library
ldapoperation.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KLDAP_LDAPOPERATION_H
00022 #define KLDAP_LDAPOPERATION_H
00023
00024 #include "kldap_export.h"
00025 #include "ldapconnection.h"
00026 #include "ldapcontrol.h"
00027 #include "ldapobject.h"
00028 #include "ldapdn.h"
00029 #include "ldapserver.h"
00030 #include "ldapurl.h"
00031
00032 #include <QtCore/QByteArray>
00033 #include <QtCore/QList>
00034 #include <QtCore/QString>
00035
00036 namespace KLDAP {
00037
00043 class KLDAP_EXPORT LdapOperation
00044 {
00045 public:
00046 typedef enum {
00047 Mod_None, Mod_Add, Mod_Replace, Mod_Del
00048 } ModType;
00049
00050 typedef enum {
00051 RES_BIND = 0x61,
00052 RES_SEARCH_ENTRY = 0x64,
00053 RES_SEARCH_REFERENCE = 0x73,
00054 RES_SEARCH_RESULT = 0x65,
00055 RES_MODIFY = 0x67,
00056 RES_ADD = 0x69,
00057 RES_DELETE = 0x69,
00058 RES_MODDN = 0x6d,
00059 RES_COMPARE = 0x6f,
00060 RES_EXTENDED = 0x78,
00061 RES_EXTENDED_PARTIAL = 0x79
00062 } ResultType;
00063
00064 typedef struct {
00065 ModType type;
00066 QString attr;
00067 QList<QByteArray> values;
00068 } ModOp ;
00069
00070 typedef QList<ModOp> ModOps;
00071
00072 enum SASL_Fields {
00073 SASL_Authname = 0x1,
00074 SASL_Authzid = 0x2,
00075 SASL_Realm = 0x4,
00076 SASL_Password = 0x8
00077 };
00078
00079 struct SASL_Credentials {
00080 int fields;
00081 QString authname;
00082 QString authzid;
00083 QString realm;
00084 QString password;
00085 };
00086
00087 typedef int (SASL_Callback_Proc) ( SASL_Credentials &cred, void *data );
00088
00089 struct SASL_Data {
00090 SASL_Callback_Proc *proc;
00091 void *data;
00092 SASL_Credentials creds;
00093 };
00094
00095 LdapOperation();
00096 LdapOperation( LdapConnection &conn );
00097 virtual ~LdapOperation();
00098
00103 void setConnection( LdapConnection &conn );
00107 LdapConnection &connection();
00111 void setClientControls( const LdapControls &ctrls );
00115 void setServerControls( const LdapControls &ctrls );
00119 LdapControls clientControls() const;
00123 LdapControls serverControls() const;
00124
00129 int bind( const QByteArray &creds = QByteArray(),
00130 SASL_Callback_Proc *saslproc = NULL, void *data = NULL );
00131
00137 int bind_s( SASL_Callback_Proc *saslproc = NULL, void *data = NULL );
00138
00143 int search( const LdapDN &base, LdapUrl::Scope scope,
00144 const QString &filter, const QStringList &attrs );
00149 int add( const LdapObject &object );
00154 int add_s( const LdapObject &object );
00159 int add( const LdapDN &dn, const ModOps &ops );
00165 int add_s( const LdapDN &dn, const ModOps &ops );
00172 int rename( const LdapDN &dn, const QString &newRdn,
00173 const QString &newSuperior, bool deleteold = true );
00180 int rename_s( const LdapDN &dn, const QString &newRdn,
00181 const QString &newSuperior, bool deleteold = true );
00186 int del( const LdapDN &dn );
00191 int del_s( const LdapDN &dn );
00196 int modify( const LdapDN &dn, const ModOps &ops );
00202 int modify_s( const LdapDN &dn, const ModOps &ops );
00208 int compare( const LdapDN &dn, const QString &attr, const QByteArray &value );
00216 int compare_s( const LdapDN &dn, const QString &attr, const QByteArray &value );
00221 int exop( const QString &oid, const QByteArray &data );
00227 int exop_s( const QString &oid, const QByteArray &data );
00231 int abandon( int id );
00244 int waitForResult( int id, int msecs = -1 );
00248 LdapObject object() const;
00253 LdapControls controls() const;
00258 QByteArray extendedOid() const;
00263 QByteArray extendedData() const;
00269 QString matchedDn() const;
00274 QList<QByteArray> referrals() const;
00279 QByteArray serverCred() const;
00280
00281 private:
00282 class LdapOperationPrivate;
00283 LdapOperationPrivate *const d;
00284
00285 Q_DISABLE_COPY( LdapOperation )
00286 };
00287
00288 }
00289
00290 #endif