Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

LDAPAsynConnection Class Reference

This class represents an asynchronous connection to an LDAP-Server. More...

#include <LDAPAsynConnection.h>

Inheritance diagram for LDAPAsynConnection:

LDAPConnection List of all members.

Public Member Functions

 LDAPAsynConnection (const std::string &hostname=std::string("localhost"), int port=389, LDAPConstraints *cons=new LDAPConstraints())
 Construtor that initializes a connection to a server.
virtual ~LDAPAsynConnection ()
void init (const std::string &hostname, int port)
 Initializes a connection to a server.
int start_tls ()
 Start TLS on this connection.
LDAPMessageQueuebind (const std::string &dn="", const std::string &passwd="", const LDAPConstraints *cons=0)
 Simple authentication to a LDAP-Server.
LDAPMessageQueuesearch (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.
LDAPMessageQueuedel (const std::string &dn, const LDAPConstraints *cons=0)
 Delete an entry from the directory.
LDAPMessageQueuecompare (const std::string &dn, const LDAPAttribute &attr, const LDAPConstraints *cons=0)
 Perform the COMPARE-operation on an attribute.
LDAPMessageQueueadd (const LDAPEntry *le, const LDAPConstraints *const =0)
 Add an entry to the directory.
LDAPMessageQueuemodify (const std::string &dn, const LDAPModList *modlist, const LDAPConstraints *cons=0)
 Apply modifications to attributes of an entry.
LDAPMessageQueuerename (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
LDAPMessageQueueextOperation (const std::string &oid, const std::string &value="", const LDAPConstraints *cons=0)
 Perform a LDAP extended Operation.
void abandon (LDAPMessageQueue *q)
 End an outstanding request.
void unbind ()
 Performs the UNBIND-operation on the destination server.
LDAP * getSessionHandle () const
const std::string & getHost () const
int getPort () const
void setConstraints (LDAPConstraints *cons)
 Change the default constraints of the connection.
const LDAPConstraintsgetConstraints () const
 Get the default constraints of the connection.
LDAPAsynConnectionreferralConnect (const LDAPUrlList &urls, LDAPUrlList::const_iterator &usedUrl, const LDAPConstraints *cons) const
 This method is used internally for automatic referral chasing.

Static Public Attributes

const int SEARCH_BASE = 0
 Constant for the Search-Operation to indicate a Base-Level Search.
const int SEARCH_ONE = 1
 Constant for the Search-Operation to indicate a One-Level Search.
const int SEARCH_SUB = 2
 Constant for the Search-Operation to indicate a subtree Search.

Protected Attributes

bool m_cacheEnabled
 Is caching enabled?

Private Member Functions

 LDAPAsynConnection (const LDAPAsynConnection &lc)
 Private copy constructor.

Private Attributes

LDAP * cur_session
 A pointer to the C-API LDAP-structure that is associated with this connection.
LDAPConstraintsm_constr
 A pointer to the default LDAPConstrains-object that is used when no LDAPConstraints-parameter is provided with a call for a LDAP-operation.
std::string m_host
 The name of the destination host.
int m_port
 The port the destination server is running on.

Detailed Description

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:
1. Create a new LDAPAsynConnection Object:
2. Use the init-method to initialize the connection
3. Call the bind-method to authenticate to the directory
4. Obtain the bind results from the return LDAPMessageQueue-Object
5. Perform on of the operations on the directory (add, delete, search, ..)
6. Use the return LDAPMessageQueue to obtain the results of the operation
7. Close the connection (feature not implemented yet :) )


Constructor & Destructor Documentation

LDAPAsynConnection::LDAPAsynConnection const std::string &  hostname = std::string("localhost"),
int  port = 389,
LDAPConstraints cons = new LDAPConstraints()
 

Construtor that initializes a connection to a server.

Parameters:
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

LDAPAsynConnection::~LDAPAsynConnection  )  [virtual]
 

LDAPAsynConnection::LDAPAsynConnection const LDAPAsynConnection lc  )  [inline, private]
 

Private copy constructor.

So nobody can call it.


Member Function Documentation

void LDAPAsynConnection::abandon LDAPMessageQueue q  ) 
 

End an outstanding request.

Parameters:
q All outstanding request related to this LDAPMessageQueue will be abandoned

LDAPMessageQueue * LDAPAsynConnection::add const LDAPEntry le,
const LDAPConstraints const = 0
 

Add an entry to the directory.

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
le The entry that will be added to the directory

Reimplemented in LDAPConnection.

LDAPMessageQueue * LDAPAsynConnection::bind const std::string &  dn = "",
const std::string &  passwd = "",
const LDAPConstraints cons = 0
 

Simple authentication to a LDAP-Server.

Exceptions:
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
Parameters:
dn the distiguished name to bind as
passwd cleartext password to use

LDAPMessageQueue * LDAPAsynConnection::compare const std::string &  dn,
const LDAPAttribute attr,
const LDAPConstraints cons = 0
 

Perform the COMPARE-operation on an attribute.

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
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

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

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
dn Distinguished name of the entry that should be deleted
cons A set of constraints that should be used with this request

Reimplemented in LDAPConnection.

LDAPMessageQueue * LDAPAsynConnection::extOperation const std::string &  oid,
const std::string &  value = "",
const LDAPConstraints cons = 0
 

Perform a LDAP extended Operation.

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
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

Reimplemented in LDAPConnection.

const LDAPConstraints * LDAPAsynConnection::getConstraints  )  const
 

Get the default constraints of the connection.

Returns:
Pointer to the LDAPConstraints-Object that is currently used with the Connection

Reimplemented in LDAPConnection.

const string & LDAPAsynConnection::getHost  )  const
 

Returns:
The Hostname of the destination server of the connection.

Reimplemented in LDAPConnection.

int LDAPAsynConnection::getPort  )  const
 

Returns:
The Port to which this connection is connecting to on the remote server.

Reimplemented in LDAPConnection.

LDAP * LDAPAsynConnection::getSessionHandle  )  const
 

Returns:
The C-APIs LDAP-structure that is associated with the current connection

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.)

Parameters:
hostname The Name or IP-Address of the destination LDAP-Server
port The Network Port the server is running on

Reimplemented in LDAPConnection.

LDAPMessageQueue * LDAPAsynConnection::modify const std::string &  dn,
const LDAPModList modlist,
const LDAPConstraints cons = 0
 

Apply modifications to attributes of an entry.

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
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

Reimplemented in LDAPConnection.

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.

Exceptions:
LDAPException in any case of an error
Parameters:
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

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

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
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

Reimplemented in LDAPConnection.

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

Exceptions:
LDAPException If the Request could not be sent to the destination server, a LDAPException-object contains the error that occured.
Parameters:
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

Reimplemented in LDAPConnection.

void LDAPAsynConnection::setConstraints LDAPConstraints cons  ) 
 

Change the default constraints of the connection.

cons cons New LDAPConstraints to use with the connection

Reimplemented in LDAPConnection.

int 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.). If you need TLS, then you should error if this call fails with an error code.

Reimplemented in LDAPConnection.

void LDAPAsynConnection::unbind  ) 
 

Performs the UNBIND-operation on the destination server.

Exceptions:
LDAPException in any case of an error

Reimplemented in LDAPConnection.


Member Data Documentation

LDAP* LDAPAsynConnection::cur_session [private]
 

A pointer to the C-API LDAP-structure that is associated with this connection.

bool LDAPAsynConnection::m_cacheEnabled [protected]
 

Is caching enabled?

LDAPConstraints* LDAPAsynConnection::m_constr [private]
 

A pointer to the default LDAPConstrains-object that is used when no LDAPConstraints-parameter is provided with a call for a LDAP-operation.

std::string LDAPAsynConnection::m_host [private]
 

The name of the destination host.

int LDAPAsynConnection::m_port [private]
 

The port the destination server is running on.

const int LDAPAsynConnection::SEARCH_BASE = 0 [static]
 

Constant for the Search-Operation to indicate a Base-Level Search.

Reimplemented in LDAPConnection.

const int LDAPAsynConnection::SEARCH_ONE = 1 [static]
 

Constant for the Search-Operation to indicate a One-Level Search.

Reimplemented in LDAPConnection.

const int LDAPAsynConnection::SEARCH_SUB = 2 [static]
 

Constant for the Search-Operation to indicate a subtree Search.

Reimplemented in LDAPConnection.


The documentation for this class was generated from the following files:
Generated on Wed Nov 12 02:19:04 2008 for ldapsdk by  doxygen 1.3.9.1