ldap_set_option(cur_session, LDAP_OPT_PROTOCOL_VERSION, &opt);
}
-int LDAPAsynConnection::start_tls(){
- return ldap_start_tls_s( cur_session, NULL, NULL );
+void LDAPAsynConnection::start_tls(){
+ int resCode;
+ if( ldap_start_tls_s( cur_session, NULL, NULL ) != LDAP_SUCCESS ) {
+ throw LDAPException(this);
+ }
}
LDAPMessageQueue* LDAPAsynConnection::bind(const string& dn,
/**
* Start TLS on this connection. This isn't in the constructor,
* because it could fail (i.e. server doesn't have SSL cert, client
- * api wasn't compiled against OpenSSL, etc.). If you need TLS,
- * then you should error if this call fails with an error code.
+ * api wasn't compiled against OpenSSL, etc.).
+ * @throws LDAPException if the TLS Layer could not be setup
+ * correctly
*/
- int start_tls();
+ void start_tls();
/** Simple authentication to a LDAP-Server
*
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,
delete msg;
throw LDAPReferralException(urls);
}else{
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
delete res;
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode,srvMsg);
+ throw LDAPException(resCode, srvMsg);
}
}
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete results; // memcheck
delete res;
delete msgq;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
return 0;
}
break;
default :
+ string srvMsg = res->getErrMsg();
delete res;
delete msg;
- throw LDAPException(resCode);
+ throw LDAPException(resCode, srvMsg);
}
}
/**
* Start TLS on this connection. This isn't in the constructor,
* because it could fail (i.e. server doesn't have SSL cert, client
- * api wasn't compiled against OpenSSL, etc.). If you need TLS,
- * then you should error if this call fails with an error code.
+ * api wasn't compiled against OpenSSL, etc.).
+ * @throws LDAPException if the TLS Layer could not be setup
+ * correctly
*/
- int start_tls();
+ void start_tls();
/**
* Performs a simple authentication with the server
using namespace std;
LDAPException::LDAPException(int res_code, const string& err_string){
- m_res_code=res_code;
- m_res_string=string(ldap_err2string(res_code));
+ m_res_code=res_code;
+ m_res_string=string(ldap_err2string(res_code));
m_err_string=err_string;
}
LDAPException::LDAPException(const LDAPAsynConnection *lc){
- m_err_string=string();
- m_res_string=string();
- LDAP *l = lc->getSessionHandle();
- ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
- m_res_string=string(ldap_err2string(m_res_code));
+ m_err_string=string();
+ m_res_string=string();
+ LDAP *l = lc->getSessionHandle();
+ ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
+ m_res_string=string(ldap_err2string(m_res_code));
char* err_string;
- ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
+ ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
m_err_string=string(err_string);
}
}
int LDAPException::getResultCode() const{
- return m_res_code;
+ return m_res_code;
}
const string& LDAPException::getResultMsg() const{
- return m_res_string;
+ return m_res_string;
}
const string& LDAPException::getServerMsg() const{