2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include "LDAPException.h"
11 #include "LDAPReferralException.h"
13 #include "LDAPAsynConnection.h"
17 LDAPException::LDAPException(int res_code, const string& err_string){
19 m_res_string=string(ldap_err2string(res_code));
20 m_err_string=err_string;
23 LDAPException::LDAPException(const LDAPAsynConnection *lc){
24 LDAP *l = lc->getSessionHandle();
25 ldap_get_option(l,LDAP_OPT_RESULT_CODE,&m_res_code);
26 const char *res_cstring = ldap_err2string(m_res_code);
28 m_res_string = string(res_cstring);
32 const char* err_string;
34 #ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
35 ldap_get_option(l,LDAP_OPT_DIAGNOSTIC_MESSAGE ,&err_string);
37 ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
40 m_err_string = string(err_string);
46 LDAPException::~LDAPException(){
49 int LDAPException::getResultCode() const{
53 const string& LDAPException::getResultMsg() const{
57 const string& LDAPException::getServerMsg() const{
61 ostream& operator << (ostream& s, LDAPException e){
62 s << "Error " << e.m_res_code << ": " << e.m_res_string;
63 if (!e.m_err_string.empty()) {
64 s << endl << "additional info: " << e.m_err_string ;