X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Fldapc%2B%2B%2Fsrc%2FLDAPConnection.cpp;h=266ef9c5a0313514ddb64efd8c7cf77cd36c43c3;hb=d2da9c1a7d1480eb6b8ae8c2a8e78392f44f4289;hp=3dde84589082eb34ee1a41d580dfb08ef9f8bfdf;hpb=f32368254d8b7b2aceecd10e3d6b02b2efd4a9cf;p=openldap diff --git a/contrib/ldapc++/src/LDAPConnection.cpp b/contrib/ldapc++/src/LDAPConnection.cpp index 3dde845890..266ef9c5a0 100644 --- a/contrib/ldapc++/src/LDAPConnection.cpp +++ b/contrib/ldapc++/src/LDAPConnection.cpp @@ -1,5 +1,6 @@ +// $OpenLDAP$ /* - * Copyright 2000, OpenLDAP Foundation, All Rights Reserved. + * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -7,7 +8,6 @@ #include "LDAPResult.h" #include "LDAPException.h" -#include "LDAPReferralException.h" #include "LDAPUrlList.h" #include "LDAPConnection.h" @@ -25,8 +25,8 @@ LDAPConnection::LDAPConnection(const string& hostname, int port, LDAPConnection::~LDAPConnection(){ } -int LDAPConnection::start_tls(){ - return LDAPAsynConnection::start_tls(); +void LDAPConnection::start_tls(){ + LDAPAsynConnection::start_tls(); } void LDAPConnection::bind(const string& dn, const string& passwd, @@ -50,15 +50,50 @@ void LDAPConnection::bind(const string& dn, const string& passwd, delete msg; throw LDAPReferralException(urls); }else{ + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } delete res; 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(); } @@ -97,9 +132,10 @@ bool LDAPConnection::compare(const string& dn, const LDAPAttribute& attr, } break; default : + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } @@ -130,9 +166,10 @@ void LDAPConnection::del(const string& dn, const LDAPConstraints* cons){ } break; default : + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } @@ -164,9 +201,10 @@ void LDAPConnection::add(const LDAPEntry* le, const LDAPConstraints* cons){ } break; default : + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } @@ -201,7 +239,7 @@ void LDAPConnection::modify(const string& dn, const LDAPModList* mods, string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode,srvMsg); + throw LDAPException(resCode, srvMsg); } } @@ -236,9 +274,10 @@ void LDAPConnection::rename(const string& dn, const string& newRDN, } break; default : + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } @@ -278,10 +317,11 @@ LDAPSearchResults* LDAPConnection::search(const string& base, int scope, } break; default : + string srvMsg = res->getErrMsg(); delete results; // memcheck delete res; delete msgq; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } return 0; @@ -314,9 +354,10 @@ LDAPExtResult* LDAPConnection::extOperation(const string& oid, } break; default : + string srvMsg = res->getErrMsg(); delete res; delete msg; - throw LDAPException(resCode); + throw LDAPException(resCode, srvMsg); } } @@ -335,3 +376,7 @@ void LDAPConnection::setConstraints(LDAPConstraints* cons){ const LDAPConstraints* LDAPConnection::getConstraints() const{ return LDAPAsynConnection::getConstraints(); } + +TlsOptions LDAPConnection::getTlsOptions() const { + return LDAPAsynConnection::getTlsOptions(); +}