]> git.sur5r.net Git - openldap/blobdiff - contrib/ldapc++/src/LDAPAsynConnection.h
Update guide Copyright/License handling
[openldap] / contrib / ldapc++ / src / LDAPAsynConnection.h
index fe00df9c2d522ae259ff4c0a84b926e814ac6b23..12cf9d803fd1da44f5af78d3ad02f7ff76ed88fc 100644 (file)
@@ -1,5 +1,6 @@
+// $OpenLDAP$
 /*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -11,7 +12,6 @@
 #include<string>
 
 #include<ldap.h>
-#include<lber.h>
 
 #include <LDAPEntry.h>
 #include <LDAPException.h>
@@ -21,6 +21,8 @@
 #include <LDAPModList.h>
 #include <LDAPUrl.h>
 #include <LDAPUrlList.h>
+#include <SaslInteractionHandler.h>
+#include <TlsOptions.h>
 
 //* Main class for an asynchronous LDAP connection 
 /**
@@ -59,9 +61,6 @@ class LDAPAsynConnection{
          * Search
          */
         static const int SEARCH_SUB=2;
-//        static const int SEARCH_SUB=LDAP_SCOPE_SUBTREE;
-//        static const int SEARCH_ONE=LDAP_SCOPE_ONELEVEL;
-//        static const int SEARCH_SUB=LDAP_SCOPE_SUBTREE;
 
         /** Construtor that initializes a connection to a server
          * @param hostname Name (or IP-Adress) of the destination host
@@ -69,12 +68,11 @@ class LDAPAsynConnection{
          * @param cons Default constraints to use with operations over 
          *      this connection
          */
-        LDAPAsynConnection(const std::string& hostname=std::string("localhost"),
+        LDAPAsynConnection(const std::string& url=std::string("localhost"),
                 int port=0, LDAPConstraints *cons=new LDAPConstraints() );
 
         //* Destructor
         virtual ~LDAPAsynConnection();
-
         /** 
          * Initializes a connection to a server. 
          * 
@@ -88,6 +86,15 @@ class LDAPAsynConnection{
          */
         void init(const std::string& hostname, int port);
 
+        /**
+         * Initializes a connection to a server. 
+         * 
+         * There actually no communication to the server. Just the
+         * object is initialized 
+         * @param uri  The LDAP-Uri for the destination
+         */ 
+        void initialize(const std::string& uri);
+
         /**
          * Start TLS on this connection.  This isn't in the constructor,
          * because it could fail (i.e. server doesn't have SSL cert, client
@@ -107,7 +114,17 @@ class LDAPAsynConnection{
          * @param dn the distiguished name to bind as
          * @param passwd cleartext password to use
          */
-        LDAPMessageQueue* bind(const std::string& dn="", const std::string& passwd="",
+        LDAPMessageQueue* bind(const std::string& dn="", 
+                const std::string& passwd="",
+                const LDAPConstraints *cons=0);
+
+        LDAPMessageQueue* saslBind(const std::string& mech, 
+                const std::string& cred, 
+                const LDAPConstraints *cons=0);
+
+        LDAPMessageQueue* saslInteractiveBind(const std::string& mech,
+                int flags=0,
+                SaslInteractionHandler *sih=0,
                 const LDAPConstraints *cons=0);
 
         /** Performing a search on a directory tree.
@@ -134,7 +151,7 @@ class LDAPAsynConnection{
                                  const StringList& attrs=StringList(), 
                                  bool attrsOnly=false,
                                  const LDAPConstraints *cons=0);
-        
+
         /** Delete an entry from the directory
          *
          * This method sends a delete request to the server
@@ -146,7 +163,7 @@ class LDAPAsynConnection{
          *              request
          */
         LDAPMessageQueue* del(const std::string& dn, const LDAPConstraints *cons=0);
-        
+
         /** 
          * Perform the COMPARE-operation on an attribute 
          *
@@ -207,7 +224,7 @@ class LDAPAsynConnection{
                 const std::string& newRDN,
                 bool delOldRDN=false, const std::string& newParentDN="",
                 const LDAPConstraints* cons=0);
-        
+
         /** Perform a LDAP extended Operation
          *
          * @throws LDAPException If the Request could not be sent to the
@@ -221,14 +238,14 @@ class LDAPAsynConnection{
          */
         LDAPMessageQueue* extOperation(const std::string& oid, 
                 const std::string& value="", const LDAPConstraints *cons=0);
-        
+
         /** End an outstanding request
          *
          * @param q All outstanding request related to this LDAPMessageQueue 
          *      will be abandoned
          */
         void abandon(LDAPMessageQueue *q);
-        
+
         /**
          * Performs the UNBIND-operation on the destination server
          * 
@@ -253,20 +270,20 @@ class LDAPAsynConnection{
          *      the remote server. 
          */
         int getPort() const;
-        
+
         /** Change the default constraints of the connection
          *
          * @parameter cons cons New LDAPConstraints to use with the connection
          */
         void setConstraints(LDAPConstraints *cons);
-        
+
         /** Get the default constraints of the connection
          *
          * @return Pointer to the LDAPConstraints-Object that is currently
          *      used with the Connection
          */
         const LDAPConstraints* getConstraints() const;
-
+        TlsOptions getTlsOptions() const;
         /**
          * This method is used internally for automatic referral chasing.
          * It tries to bind to a destination server of the URLs of a
@@ -291,7 +308,7 @@ class LDAPAsynConnection{
          * Private copy constructor. So nobody can call it.
          */
         LDAPAsynConnection(const LDAPAsynConnection& lc){};
-        
+
         /**
          * A pointer to the C-API LDAP-structure that is associated with
          * this connection
@@ -306,16 +323,11 @@ class LDAPAsynConnection{
         LDAPConstraints *m_constr;
 
         /**
-         * The name of the destination host
-         */
-        std::string m_host;
-
-        /**
-         * The port the destination server is running on.
+         * The URI of this connection
          */
-        int m_port;
+        LDAPUrl m_uri;
 
- protected:
   protected:
         /**
          * Is caching enabled?
          */