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(), SASL_Callback_Proc *saslproc = NULL, void *data = NULL );
00130
00136 int bind_s( SASL_Callback_Proc *saslproc = NULL, void *data = NULL );
00137
00142 int search( const LdapDN &base, LdapUrl::Scope scope,
00143 const QString &filter, const QStringList &attrs );
00148 int add( const LdapObject &object );
00153 int add_s( const LdapObject &object );
00158 int add( const LdapDN &dn, const ModOps &ops );
00164 int add_s( const LdapDN &dn, const ModOps &ops );
00171 int rename( const LdapDN &dn, const QString &newRdn,
00172 const QString &newSuperior, bool deleteold = true );
00179 int rename_s( const LdapDN &dn, const QString &newRdn,
00180 const QString &newSuperior, bool deleteold = true );
00185 int del( const LdapDN &dn );
00190 int del_s( const LdapDN &dn );
00195 int modify( const LdapDN &dn, const ModOps &ops );
00201 int modify_s( const LdapDN &dn, const ModOps &ops );
00207 int compare( const LdapDN &dn, const QString &attr, const QByteArray &value );
00215 int compare_s( const LdapDN &dn, const QString &attr, const QByteArray &value );
00220 int exop( const QString &oid, const QByteArray &data );
00226 int exop_s( const QString &oid, const QByteArray &data );
00230 int abandon( int id );
00243 int waitForResult( int id, int msecs = -1 );
00247 LdapObject object() const;
00252 LdapControls controls() const;
00257 QByteArray extendedOid() const;
00262 QByteArray extendedData() const;
00268 QString matchedDn() const;
00273 QList<QByteArray> referrals() const;
00278 QByteArray serverCred() const;
00279
00280 private:
00281 class LdapOperationPrivate;
00282 LdapOperationPrivate *const d;
00283
00284 Q_DISABLE_COPY( LdapOperation )
00285 };
00286
00287 }
00288
00289 #endif