Back to index

openldap  2.4.31
LDAPAsynConnection.h
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #ifndef LDAP_ASYN_CONNECTION_H
00009 #define LDAP_ASYN_CONNECTION_H
00010 
00011 #include<iostream>
00012 #include<string>
00013 
00014 #include<ldap.h>
00015 
00016 #include <LDAPEntry.h>
00017 #include <LDAPException.h>
00018 #include <LDAPMessageQueue.h>
00019 #include <LDAPConstraints.h>
00020 #include <LDAPModification.h>
00021 #include <LDAPModList.h>
00022 #include <LDAPUrl.h>
00023 #include <LDAPUrlList.h>
00024 #include <SaslInteractionHandler.h>
00025 #include <TlsOptions.h>
00026 
00027 //* Main class for an asynchronous LDAP connection 
00045 class LDAPAsynConnection{
00046     public :
00051         static const int SEARCH_BASE=0;
00052         
00057         static const int SEARCH_ONE=1;
00058         
00063         static const int SEARCH_SUB=2;
00064 
00071         LDAPAsynConnection(const std::string& url=std::string("localhost"),
00072                 int port=0, LDAPConstraints *cons=new LDAPConstraints() );
00073 
00074         //* Destructor
00075         virtual ~LDAPAsynConnection();
00087         void init(const std::string& hostname, int port);
00088 
00096         void initialize(const std::string& uri);
00097 
00105         void start_tls();
00106 
00117         LDAPMessageQueue* bind(const std::string& dn="", 
00118                 const std::string& passwd="",
00119                 const LDAPConstraints *cons=0);
00120 
00121         LDAPMessageQueue* saslBind(const std::string& mech, 
00122                 const std::string& cred, 
00123                 const LDAPConstraints *cons=0);
00124 
00125         LDAPMessageQueue* saslInteractiveBind(const std::string& mech,
00126                 int flags=0,
00127                 SaslInteractionHandler *sih=0,
00128                 const LDAPConstraints *cons=0);
00129 
00149         LDAPMessageQueue* search(const std::string& base="", int scope=0, 
00150                                  const std::string& filter="objectClass=*", 
00151                                  const StringList& attrs=StringList(), 
00152                                  bool attrsOnly=false,
00153                                  const LDAPConstraints *cons=0);
00154 
00165         LDAPMessageQueue* del(const std::string& dn, const LDAPConstraints *cons=0);
00166 
00180         LDAPMessageQueue* compare(const std::string& dn, 
00181                 const LDAPAttribute& attr, 
00182                 const LDAPConstraints *cons=0);
00183 
00191         LDAPMessageQueue* add( const LDAPEntry* le,
00192                 const LDAPConstraints *const=0);
00193 
00205         LDAPMessageQueue* modify(const std::string& dn, 
00206                 const LDAPModList *modlist,
00207                 const LDAPConstraints *cons=0);
00208 
00223         LDAPMessageQueue* rename(const std::string& dn, 
00224                 const std::string& newRDN,
00225                 bool delOldRDN=false, const std::string& newParentDN="",
00226                 const LDAPConstraints* cons=0);
00227 
00239         LDAPMessageQueue* extOperation(const std::string& oid, 
00240                 const std::string& value="", const LDAPConstraints *cons=0);
00241 
00247         void abandon(LDAPMessageQueue *q);
00248 
00254         void unbind();
00255 
00260         LDAP* getSessionHandle() const ;
00261 
00266         const std::string& getHost() const;
00267 
00272         int getPort() const;
00273 
00278         void setConstraints(LDAPConstraints *cons);
00279 
00285         const LDAPConstraints* getConstraints() const;
00286         TlsOptions getTlsOptions() const;
00302         LDAPAsynConnection* referralConnect(const LDAPUrlList& urls,
00303                 LDAPUrlList::const_iterator& usedUrl,
00304                 const LDAPConstraints* cons) const;
00305 
00306     private :
00310         LDAPAsynConnection(const LDAPAsynConnection& lc){};
00311 
00316         LDAP *cur_session;
00317 
00323         LDAPConstraints *m_constr;
00324 
00328         LDAPUrl m_uri;
00329 
00330     protected:
00334         bool m_cacheEnabled;
00335 };
00336 #endif //LDAP_ASYN_CONNECTION_H
00337 
00338