2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2000-09-01 14:46:32 -04:00
|
|
|
/*
|
2015-02-11 16:36:57 -05:00
|
|
|
* Copyright 2000-2015 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-01 14:46:32 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LDAP_EXCEPTION_H
|
|
|
|
|
#define LDAP_EXCEPTION_H
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2000-10-03 14:25:34 -04:00
|
|
|
#include <string>
|
2008-03-20 11:08:29 -04:00
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
#include <LDAPUrlList.h>
|
2000-10-03 14:25:34 -04:00
|
|
|
|
|
|
|
|
class LDAPAsynConnection;
|
2000-09-01 14:46:32 -04:00
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* This class is only thrown as an Exception and used to signalize error
|
|
|
|
|
* conditions during LDAP-operations
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
class LDAPException : public std::runtime_error
|
|
|
|
|
{
|
2000-09-01 14:46:32 -04:00
|
|
|
|
2006-07-03 12:29:30 -04:00
|
|
|
public :
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* Constructs a LDAPException-object from the parameters
|
|
|
|
|
* @param res_code A valid LDAP result code.
|
2002-04-23 11:28:11 -04:00
|
|
|
* @param err_string An addional error message for the error
|
2001-02-19 06:34:28 -05:00
|
|
|
* that happend (optional)
|
|
|
|
|
*/
|
2006-07-03 12:29:30 -04:00
|
|
|
LDAPException(int res_code,
|
2008-03-20 11:08:29 -04:00
|
|
|
const std::string& err_string=std::string()) throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a LDAPException-object from the error state of a
|
|
|
|
|
* LDAPAsynConnection-object
|
|
|
|
|
* @param lc A LDAP-Connection for that an error has happend. The
|
|
|
|
|
* Constructor tries to read its error state.
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
LDAPException(const LDAPAsynConnection *lc) throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
virtual ~LDAPException() throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The Result code of the object
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
int getResultCode() const throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The error message that is corresponding to the result
|
|
|
|
|
* code .
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
const std::string& getResultMsg() const throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The addional error message of the error (if it was set)
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
const std::string& getServerMsg() const throw();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual const char* what() const throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method can be used to dump the data of a LDAPResult-Object.
|
|
|
|
|
* It is only useful for debugging purposes at the moment
|
|
|
|
|
*/
|
2008-03-20 11:08:29 -04:00
|
|
|
friend std::ostream& operator << (std::ostream &s, LDAPException e) throw();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
2006-07-03 12:29:30 -04:00
|
|
|
private :
|
|
|
|
|
int m_res_code;
|
|
|
|
|
std::string m_res_string;
|
|
|
|
|
std::string m_err_string;
|
2000-09-01 14:46:32 -04:00
|
|
|
};
|
2008-03-20 11:08:29 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class extends LDAPException and is used to signalize Referrals
|
|
|
|
|
* there were received during synchronous LDAP-operations
|
|
|
|
|
*/
|
|
|
|
|
class LDAPReferralException : public LDAPException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public :
|
|
|
|
|
/**
|
|
|
|
|
* Creates an object that is initialized with a list of URLs
|
|
|
|
|
*/
|
|
|
|
|
LDAPReferralException(const LDAPUrlList& urls) throw();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
~LDAPReferralException() throw();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The List of URLs of the Referral/Search Reference
|
|
|
|
|
*/
|
|
|
|
|
const LDAPUrlList& getUrls() throw();
|
|
|
|
|
|
|
|
|
|
private :
|
|
|
|
|
LDAPUrlList m_urlList;
|
|
|
|
|
};
|
|
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
#endif //LDAP_EXCEPTION_H
|