ldapsdk
0.0.1
|
This class represents an asynchronous connection to an LDAP-Server. More...
#include <LDAPAsynConnection.h>
Public Member Functions | |
LDAPAsynConnection (const std::string &url=std::string("localhost"), int port=0, LDAPConstraints *cons=new LDAPConstraints()) | |
Construtor that initializes a connection to a server. More... | |
virtual | ~LDAPAsynConnection () |
void | init (const std::string &hostname, int port) |
Initializes a connection to a server. More... | |
void | initialize (const std::string &uri) |
Initializes a connection to a server. More... | |
void | start_tls () |
Start TLS on this connection. More... | |
LDAPMessageQueue * | bind (const std::string &dn="", const std::string &passwd="", const LDAPConstraints *cons=0) |
Simple authentication to a LDAP-Server. More... | |
LDAPMessageQueue * | saslBind (const std::string &mech, const std::string &cred, const LDAPConstraints *cons=0) |
LDAPMessageQueue * | saslInteractiveBind (const std::string &mech, int flags=0, SaslInteractionHandler *sih=0, const LDAPConstraints *cons=0) |
LDAPMessageQueue * | search (const std::string &base="", int scope=0, const std::string &filter="objectClass=*", const StringList &attrs=StringList(), bool attrsOnly=false, const LDAPConstraints *cons=0) |
Performing a search on a directory tree. More... | |
LDAPMessageQueue * | del (const std::string &dn, const LDAPConstraints *cons=0) |
Delete an entry from the directory. More... | |
LDAPMessageQueue * | compare (const std::string &dn, const LDAPAttribute &attr, const LDAPConstraints *cons=0) |
Perform the COMPARE-operation on an attribute. More... | |
LDAPMessageQueue * | add (const LDAPEntry *le, const LDAPConstraints *const=0) |
Add an entry to the directory. More... | |
LDAPMessageQueue * | modify (const std::string &dn, const LDAPModList *modlist, const LDAPConstraints *cons=0) |
Apply modifications to attributes of an entry. More... | |
LDAPMessageQueue * | rename (const std::string &dn, const std::string &newRDN, bool delOldRDN=false, const std::string &newParentDN="", const LDAPConstraints *cons=0) |
modify the DN of an entry More... | |
LDAPMessageQueue * | extOperation (const std::string &oid, const std::string &value="", const LDAPConstraints *cons=0) |
Perform a LDAP extended Operation. More... | |
void | abandon (LDAPMessageQueue *q) |
End an outstanding request. More... | |
void | unbind () |
Performs the UNBIND-operation on the destination server. More... | |
LDAP * | getSessionHandle () const |
const std::string & | getHost () const |
int | getPort () const |
void | setConstraints (LDAPConstraints *cons) |
Change the default constraints of the connection. More... | |
const LDAPConstraints * | getConstraints () const |
Get the default constraints of the connection. More... | |
TlsOptions | getTlsOptions () const |
LDAPAsynConnection * | referralConnect (const LDAPUrlList &urls, LDAPUrlList::const_iterator &usedUrl, const LDAPConstraints *cons) const |
This method is used internally for automatic referral chasing. More... | |
Static Public Attributes | |
static const int | SEARCH_BASE =0 |
Constant for the Search-Operation to indicate a Base-Level Search. More... | |
static const int | SEARCH_ONE =1 |
Constant for the Search-Operation to indicate a One-Level Search. More... | |
static const int | SEARCH_SUB =2 |
Constant for the Search-Operation to indicate a subtree Search. More... | |
Protected Attributes | |
bool | m_cacheEnabled |
Is caching enabled? More... | |
This class represents an asynchronous connection to an LDAP-Server.
It provides the methods for authentication, and all other LDAP-Operations (e.g. search, add, delete, etc.) All of the LDAP-Operations return a pointer to a LDAPMessageQueue-Object, which can be used to obtain the results of that operation. A basic example of this class could be like this:
LDAPAsynConnection::LDAPAsynConnection | ( | const std::string & | url = std::string("localhost") , |
int | port = 0 , |
||
LDAPConstraints * | cons = new LDAPConstraints() |
||
) |
Construtor that initializes a connection to a server.
hostname | Name (or IP-Adress) of the destination host |
port | Port the LDAP server is running on |
cons | Default constraints to use with operations over this connection |
|
virtual |
void LDAPAsynConnection::abandon | ( | LDAPMessageQueue * | q | ) |
End an outstanding request.
q | All outstanding request related to this LDAPMessageQueue will be abandoned |
References DEBUG, LDAPRequest::getMsgID(), LDAPMessageQueue::getRequestStack(), and LDAP_DEBUG_TRACE.
LDAPMessageQueue * LDAPAsynConnection::add | ( | const LDAPEntry * | le, |
const LDAPConstraints * const | cons = 0 |
||
) |
Add an entry to the directory.
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
le | The entry that will be added to the directory |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPAddRequest::sendRequest().
Referenced by LDAPConnection::add().
LDAPMessageQueue * LDAPAsynConnection::bind | ( | const std::string & | dn = "" , |
const std::string & | passwd = "" , |
||
const LDAPConstraints * | cons = 0 |
||
) |
Simple authentication to a LDAP-Server.
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. This method does a simple (username, password) bind to the server. Other, saver, authentcation methods are provided later |
dn | the distiguished name to bind as |
passwd | cleartext password to use |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPBindRequest::sendRequest().
Referenced by LDAPConnection::bind().
LDAPMessageQueue * LDAPAsynConnection::compare | ( | const std::string & | dn, |
const LDAPAttribute & | attr, | ||
const LDAPConstraints * | cons = 0 |
||
) |
Perform the COMPARE-operation on an attribute.
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
dn | Distinguished name of the entry for which the compare should be performed |
attr | An Attribute (one (!) value) to use for the compare operation |
cons | A set of constraints that should be used with this request |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPCompareRequest::sendRequest().
Referenced by LDAPConnection::compare().
LDAPMessageQueue * LDAPAsynConnection::del | ( | const std::string & | dn, |
const LDAPConstraints * | cons = 0 |
||
) |
Delete an entry from the directory.
This method sends a delete request to the server
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
dn | Distinguished name of the entry that should be deleted |
cons | A set of constraints that should be used with this request |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPDeleteRequest::sendRequest().
Referenced by LDAPConnection::del().
LDAPMessageQueue * LDAPAsynConnection::extOperation | ( | const std::string & | oid, |
const std::string & | value = "" , |
||
const LDAPConstraints * | cons = 0 |
||
) |
Perform a LDAP extended Operation.
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
oid | The dotted decimal representation of the extended Operation that should be performed |
value | The data asociated with this operation |
cons | A set of constraints that should be used with this request |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPExtRequest::sendRequest().
Referenced by LDAPConnection::extOperation().
const LDAPConstraints * LDAPAsynConnection::getConstraints | ( | ) | const |
Get the default constraints of the connection.
References DEBUG, and LDAP_DEBUG_TRACE.
Referenced by LDAPConnection::getConstraints(), and LDAPRequest::LDAPRequest().
const string & LDAPAsynConnection::getHost | ( | ) | const |
References DEBUG, and LDAP_DEBUG_TRACE.
Referenced by LDAPRequest::equals(), and LDAPConnection::getHost().
int LDAPAsynConnection::getPort | ( | ) | const |
References DEBUG, and LDAP_DEBUG_TRACE.
Referenced by LDAPRequest::equals(), and LDAPConnection::getPort().
LDAP * LDAPAsynConnection::getSessionHandle | ( | ) | const |
References DEBUG, and LDAP_DEBUG_TRACE.
Referenced by LDAPAttributeList::LDAPAttributeList(), LDAPEntry::LDAPEntry(), LDAPExtResult::LDAPExtResult(), LDAPResult::LDAPResult(), LDAPSaslBindResult::LDAPSaslBindResult(), LDAPSearchReference::LDAPSearchReference(), LDAPSearchResult::LDAPSearchResult(), referralConnect(), LDAPDeleteRequest::sendRequest(), LDAPExtRequest::sendRequest(), LDAPCompareRequest::sendRequest(), LDAPModDNRequest::sendRequest(), LDAPAddRequest::sendRequest(), LDAPModifyRequest::sendRequest(), LDAPBindRequest::sendRequest(), LDAPSearchRequest::sendRequest(), LDAPSaslBindRequest::sendRequest(), and LDAPSaslInteractiveBind::sendRequest().
TlsOptions LDAPAsynConnection::getTlsOptions | ( | ) | const |
Referenced by LDAPConnection::getTlsOptions().
void LDAPAsynConnection::init | ( | const std::string & | hostname, |
int | port | ||
) |
Initializes a connection to a server.
There actually no communication to the server. Just the object is initialized (e.g. this method is called within the LDAPAsynConnection(char*,int,LDAPConstraints) constructor.)
hostname | The Name or IP-Address of the destination LDAP-Server |
port | The Network Port the server is running on |
References DEBUG, LDAP_DEBUG_PARAMETER, and LDAP_DEBUG_TRACE.
void LDAPAsynConnection::initialize | ( | const std::string & | uri | ) |
Initializes a connection to a server.
There actually no communication to the server. Just the object is initialized
uri | The LDAP-Uri for the destination |
LDAPMessageQueue * LDAPAsynConnection::modify | ( | const std::string & | dn, |
const LDAPModList * | modlist, | ||
const LDAPConstraints * | cons = 0 |
||
) |
Apply modifications to attributes of an entry.
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
dn | Distiguished Name of the Entry to modify |
modlist | A set of modification that should be applied to the Entry |
cons | A set of constraints that should be used with this request |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPModifyRequest::sendRequest().
Referenced by LDAPConnection::modify().
LDAPAsynConnection * LDAPAsynConnection::referralConnect | ( | const LDAPUrlList & | urls, |
LDAPUrlList::const_iterator & | usedUrl, | ||
const LDAPConstraints * | cons | ||
) | const |
This method is used internally for automatic referral chasing.
It tries to bind to a destination server of the URLs of a referral.
LDAPException | in any case of an error |
urls | Contains a std::list of LDAP-Urls that indicate the destinations of a referral |
usedUrl | After this method has successfully bind to one of the Destination URLs this parameter contains the URLs which was contacted. |
cons | An LDAPConstraints-Object that should be used for the new connection. If this object contains a LDAPRebind-object it is used to bind to the new server |
References LDAPUrlList::begin(), DEBUG, LDAPUrlList::end(), LDAPRebindAuth::getDN(), LDAPRebindAuth::getPassword(), LDAPRebind::getRebindAuth(), LDAPConstraints::getReferralRebind(), getSessionHandle(), and LDAP_DEBUG_TRACE.
Referenced by LDAPDeleteRequest::followReferral(), LDAPExtRequest::followReferral(), LDAPCompareRequest::followReferral(), LDAPModDNRequest::followReferral(), LDAPAddRequest::followReferral(), LDAPModifyRequest::followReferral(), and LDAPSearchRequest::followReferral().
LDAPMessageQueue * LDAPAsynConnection::rename | ( | const std::string & | dn, |
const std::string & | newRDN, | ||
bool | delOldRDN = false , |
||
const std::string & | newParentDN = "" , |
||
const LDAPConstraints * | cons = 0 |
||
) |
modify the DN of an entry
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
dn | DN to modify |
newRDN | The new relative DN for the entry |
delOldRDN | true=The old RDN will be removed from the attributes false=The old RDN will still be present in the attributes of the entry |
newParentDN | The DN of the new parent entry of the entry 0 to keep the old one |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPModDNRequest::sendRequest().
Referenced by LDAPConnection::rename().
LDAPMessageQueue * LDAPAsynConnection::saslBind | ( | const std::string & | mech, |
const std::string & | cred, | ||
const LDAPConstraints * | cons = 0 |
||
) |
References DEBUG, LDAP_DEBUG_TRACE, and LDAPSaslBindRequest::sendRequest().
LDAPMessageQueue * LDAPAsynConnection::saslInteractiveBind | ( | const std::string & | mech, |
int | flags = 0 , |
||
SaslInteractionHandler * | sih = 0 , |
||
const LDAPConstraints * | cons = 0 |
||
) |
References DEBUG, LDAP_DEBUG_TRACE, and LDAPSaslInteractiveBind::sendRequest().
Referenced by LDAPConnection::saslInteractiveBind().
LDAPMessageQueue * LDAPAsynConnection::search | ( | const std::string & | base = "" , |
int | scope = 0 , |
||
const std::string & | filter = "objectClass=*" , |
||
const StringList & | attrs = StringList() , |
||
bool | attrsOnly = false , |
||
const LDAPConstraints * | cons = 0 |
||
) |
Performing a search on a directory tree.
Use the search method to perform a search on the LDAP-Directory
LDAPException | If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured. |
base | The distinguished name of the starting point for the search operation |
scope | The scope of the search. Possible values: LDAPAsynConnection::SEARCH_BASE, LDAPAsynConnection::SEARCH_ONE, LDAPAsynConnection::SEARCH_SUB |
filter | The std::string representation of a search filter to use with this operation |
attrsOnly | true if only the attributes names (no values) should be returned |
cons | A set of constraints that should be used with this request |
References DEBUG, LDAP_DEBUG_PARAMETER, LDAP_DEBUG_TRACE, and LDAPSearchRequest::sendRequest().
Referenced by LDAPConnection::search().
void LDAPAsynConnection::setConstraints | ( | LDAPConstraints * | cons | ) |
Change the default constraints of the connection.
cons cons New LDAPConstraints to use with the connection
References DEBUG, and LDAP_DEBUG_TRACE.
Referenced by LDAPConnection::setConstraints().
void LDAPAsynConnection::start_tls | ( | ) |
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.).
LDAPException | if the TLS Layer could not be setup correctly |
Referenced by LDAPConnection::start_tls().
void LDAPAsynConnection::unbind | ( | ) |
Performs the UNBIND-operation on the destination server.
LDAPException | in any case of an error |
References DEBUG, LDAPControlSet::freeLDAPControlArray(), and LDAP_DEBUG_TRACE.
Referenced by LDAPConnection::unbind().
|
protected |
Is caching enabled?
|
static |
Constant for the Search-Operation to indicate a Base-Level Search.
Referenced by LDAPSearchRequest::followReferral().
|
static |
Constant for the Search-Operation to indicate a One-Level Search.
Referenced by LDAPSearchRequest::followReferral().
|
static |
Constant for the Search-Operation to indicate a subtree Search.