]> git.sur5r.net Git - openldap/blobdiff - contrib/ldapc++/src/LDAPAsynConnection.cpp
initial support for SASL
[openldap] / contrib / ldapc++ / src / LDAPAsynConnection.cpp
index edff84d95cbc3cc12c911dca7e41a0b06372ca9d..95539719461d849bbfb6d9acd88f9d8fc1858064 100644 (file)
 
 using namespace std;
 
-LDAPAsynConnection::LDAPAsynConnection(const string& hostname, int port,
+LDAPAsynConnection::LDAPAsynConnection(const string& url, int port,
                                LDAPConstraints *cons ){
     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPAsynConnection::LDAPAsynConnection()"
             << endl);
     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
-            "   host:" << hostname << endl << "   port:" << port << endl);
+            "   URL:" << url << endl << "   port:" << port << endl);
     cur_session=0;
     m_constr = 0;
-    this->init(hostname, port);
+    // Is this an LDAP URI?
+    if ( url.find("://") == std::string::npos ) {
+       this->init(url, port);
+    } else {
+       this->initialize(url);
+    }
     this->setConstraints(cons);
 }
 
@@ -95,6 +100,41 @@ LDAPMessageQueue* LDAPAsynConnection::bind(const string& dn,
     }
 }
 
+LDAPMessageQueue* LDAPAsynConnection::saslBind(const std::string &mech,
+               const std::string &cred,
+               const LDAPConstraints *cons)
+{
+    DEBUG(LDAP_DEBUG_TRACE, "LDAPAsynConnection::saslBind()" <<  endl);
+    LDAPSaslBindRequest *req = new LDAPSaslBindRequest(mech, cred, this, cons);
+    try{
+        LDAPMessageQueue *ret = req->sendRequest();
+        return ret;
+    }catch(LDAPException e){
+        delete req;
+        throw;
+    }
+
+}
+
+LDAPMessageQueue* LDAPAsynConnection::saslInteractiveBind(
+                        const std::string &mech,
+                        int flags,
+                        SaslInteractionHandler *sih,
+                        const LDAPConstraints *cons)
+{
+    DEBUG(LDAP_DEBUG_TRACE, "LDAPAsynConnection::saslInteractiveBind" 
+            << std::endl);
+    LDAPSaslInteractiveBind *req = 
+            new LDAPSaslInteractiveBind(mech, flags, sih, this, cons);
+    try {
+        LDAPMessageQueue *ret = req->sendRequest();
+        return ret;
+    }catch(LDAPException e){
+        delete req;
+        throw;
+    } 
+}
+
 LDAPMessageQueue* LDAPAsynConnection::search(const string& base,int scope, 
                                          const string& filter, 
                                          const StringList& attrs,