mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
improved error reporting
This commit is contained in:
parent
7389cb27ed
commit
00c7cf396b
@ -56,8 +56,11 @@ void LDAPAsynConnection::init(const string& hostname, int port){
|
|||||||
ldap_set_option(cur_session, LDAP_OPT_PROTOCOL_VERSION, &opt);
|
ldap_set_option(cur_session, LDAP_OPT_PROTOCOL_VERSION, &opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LDAPAsynConnection::start_tls(){
|
void LDAPAsynConnection::start_tls(){
|
||||||
return ldap_start_tls_s( cur_session, NULL, NULL );
|
int resCode;
|
||||||
|
if( ldap_start_tls_s( cur_session, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||||
|
throw LDAPException(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LDAPMessageQueue* LDAPAsynConnection::bind(const string& dn,
|
LDAPMessageQueue* LDAPAsynConnection::bind(const string& dn,
|
||||||
|
@ -92,10 +92,11 @@ class LDAPAsynConnection{
|
|||||||
/**
|
/**
|
||||||
* Start TLS on this connection. This isn't in the constructor,
|
* Start TLS on this connection. This isn't in the constructor,
|
||||||
* because it could fail (i.e. server doesn't have SSL cert, client
|
* because it could fail (i.e. server doesn't have SSL cert, client
|
||||||
* api wasn't compiled against OpenSSL, etc.). If you need TLS,
|
* api wasn't compiled against OpenSSL, etc.).
|
||||||
* then you should error if this call fails with an error code.
|
* @throws LDAPException if the TLS Layer could not be setup
|
||||||
|
* correctly
|
||||||
*/
|
*/
|
||||||
int start_tls();
|
void start_tls();
|
||||||
|
|
||||||
/** Simple authentication to a LDAP-Server
|
/** Simple authentication to a LDAP-Server
|
||||||
*
|
*
|
||||||
|
@ -25,8 +25,8 @@ LDAPConnection::LDAPConnection(const string& hostname, int port,
|
|||||||
LDAPConnection::~LDAPConnection(){
|
LDAPConnection::~LDAPConnection(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int LDAPConnection::start_tls(){
|
void LDAPConnection::start_tls(){
|
||||||
return LDAPAsynConnection::start_tls();
|
LDAPAsynConnection::start_tls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LDAPConnection::bind(const string& dn, const string& passwd,
|
void LDAPConnection::bind(const string& dn, const string& passwd,
|
||||||
@ -50,9 +50,10 @@ void LDAPConnection::bind(const string& dn, const string& passwd,
|
|||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPReferralException(urls);
|
throw LDAPReferralException(urls);
|
||||||
}else{
|
}else{
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete res;
|
delete res;
|
||||||
@ -97,9 +98,10 @@ bool LDAPConnection::compare(const string& dn, const LDAPAttribute& attr,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +132,10 @@ void LDAPConnection::del(const string& dn, const LDAPConstraints* cons){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -164,9 +167,10 @@ void LDAPConnection::add(const LDAPEntry* le, const LDAPConstraints* cons){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +205,7 @@ void LDAPConnection::modify(const string& dn, const LDAPModList* mods,
|
|||||||
string srvMsg = res->getErrMsg();
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode,srvMsg);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -236,9 +240,10 @@ void LDAPConnection::rename(const string& dn, const string& newRDN,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,10 +283,11 @@ LDAPSearchResults* LDAPConnection::search(const string& base, int scope,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete results; // memcheck
|
delete results; // memcheck
|
||||||
delete res;
|
delete res;
|
||||||
delete msgq;
|
delete msgq;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -314,9 +320,10 @@ LDAPExtResult* LDAPConnection::extOperation(const string& oid,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
string srvMsg = res->getErrMsg();
|
||||||
delete res;
|
delete res;
|
||||||
delete msg;
|
delete msg;
|
||||||
throw LDAPException(resCode);
|
throw LDAPException(resCode, srvMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,10 +71,11 @@ class LDAPConnection : private LDAPAsynConnection {
|
|||||||
/**
|
/**
|
||||||
* Start TLS on this connection. This isn't in the constructor,
|
* Start TLS on this connection. This isn't in the constructor,
|
||||||
* because it could fail (i.e. server doesn't have SSL cert, client
|
* because it could fail (i.e. server doesn't have SSL cert, client
|
||||||
* api wasn't compiled against OpenSSL, etc.). If you need TLS,
|
* api wasn't compiled against OpenSSL, etc.).
|
||||||
* then you should error if this call fails with an error code.
|
* @throws LDAPException if the TLS Layer could not be setup
|
||||||
|
* correctly
|
||||||
*/
|
*/
|
||||||
int start_tls();
|
void start_tls();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a simple authentication with the server
|
* Performs a simple authentication with the server
|
||||||
|
Loading…
Reference in New Issue
Block a user