From ee846c174cc1403cdad2894de8a74f466c547ca8 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 1 Apr 2008 16:35:42 +0000 Subject: [PATCH] SASL support for LDAPConnection --- contrib/ldapc++/src/LDAPConnection.cpp | 34 ++++++++++++++++++++++++++ contrib/ldapc++/src/LDAPConnection.h | 4 +++ 2 files changed, 38 insertions(+) diff --git a/contrib/ldapc++/src/LDAPConnection.cpp b/contrib/ldapc++/src/LDAPConnection.cpp index 9b76fcb342..5a86029424 100644 --- a/contrib/ldapc++/src/LDAPConnection.cpp +++ b/contrib/ldapc++/src/LDAPConnection.cpp @@ -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(); } diff --git a/contrib/ldapc++/src/LDAPConnection.h b/contrib/ldapc++/src/LDAPConnection.h index 15f3ae8fe6..2e8cb0ad82 100644 --- a/contrib/ldapc++/src/LDAPConnection.h +++ b/contrib/ldapc++/src/LDAPConnection.h @@ -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 -- 2.39.5