]> git.sur5r.net Git - openldap/commitdiff
SASL support for LDAPConnection
authorRalf Haferkamp <ralf@openldap.org>
Tue, 1 Apr 2008 16:35:42 +0000 (16:35 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Tue, 1 Apr 2008 16:35:42 +0000 (16:35 +0000)
contrib/ldapc++/src/LDAPConnection.cpp
contrib/ldapc++/src/LDAPConnection.h

index 9b76fcb342cecc9a9031dbf2cb18b4596981c15c..5a86029424df282794b3188ad5076dfcf6d06635 100644 (file)
@@ -60,6 +60,40 @@ void LDAPConnection::bind(const string& dn, const string& passwd,
     delete msg;   // memcheck
 }
 
+void LDAPConnection::saslInteractiveBind( const std::string &mech,
+                        int flags,
+                        SaslInteractionHandler *sih,
+                        const LDAPConstraints *cons)
+{
+    DEBUG(LDAP_DEBUG_TRACE,"LDAPConnection::bind" << endl);
+    LDAPMessageQueue* msg=0;
+    LDAPResult* res=0;
+    try{
+        msg = LDAPAsynConnection::saslInteractiveBind(mech, flags, sih, cons);
+        res = (LDAPResult*)msg->getNext();
+    }catch(LDAPException e){
+        delete msg;
+        delete res;
+        throw;
+    }
+    int resCode=res->getResultCode();
+    if(resCode != LDAPResult::SUCCESS) {
+        if(resCode == LDAPResult::REFERRAL){
+            LDAPUrlList urls = res->getReferralUrls();
+            delete res;
+            delete msg;
+            throw LDAPReferralException(urls);
+        }else{
+            string srvMsg = res->getErrMsg();
+            delete res;
+            delete msg;
+            throw LDAPException(resCode, srvMsg);
+        }
+    }
+    delete res;
+    delete msg;
+}
+
 void LDAPConnection::unbind(){
     LDAPAsynConnection::unbind();
 }
index 15f3ae8fe683b8251383a651f6cfddcc3698e8b5..2e8cb0ad8223cc016f6dc449d90213ae7b6e6a2e 100644 (file)
@@ -89,6 +89,10 @@ class LDAPConnection : private LDAPAsynConnection {
          */
         void bind(const std::string& dn="", const std::string& passwd="",
                 LDAPConstraints* cons=0);
+        void saslInteractiveBind(const std::string& mech,
+                int flags=0,
+                SaslInteractionHandler *sih=0,
+                const LDAPConstraints *cons=0);
         
         /**
          * Performs the UNBIND-operation on the destination server