PLDAPSession Class Reference

This class will create an LDAP client to access a remote LDAP server. More...

#include <pldap.h>

Inheritance diagram for PLDAPSession:

PObject PILSSession List of all members.

Public Types

 AuthSimple
 AuthSASL
 AuthKerberos
 NumAuthenticationMethod
 ScopeBaseOnly
 ScopeSingleLevel
 ScopeSubTree
 NumSearchScope
enum  AuthenticationMethod { AuthSimple, AuthSASL, AuthKerberos, NumAuthenticationMethod }
enum  SearchScope { ScopeBaseOnly, ScopeSingleLevel, ScopeSubTree, NumSearchScope }

Public Member Functions

 PLDAPSession (const PString &defaultBaseDN=PString::Empty())
 Create a LDAP client.
 ~PLDAPSession ()
 Close the sesison on destruction.
PBoolean Open (const PString &server, WORD port=0)
 Open the LDAP session to the specified server.
PBoolean Close ()
 Close the LDAP session.
PBoolean IsOpen () const
 Determine of session is open.
PBoolean SetOption (int optcode, int value)
 Set LDAP option parameter (OpenLDAp specific values).
PBoolean SetOption (int optcode, void *value)
 Set LDAP option parameter (OpenLDAP specific values).
PBoolean Bind (const PString &who=PString::Empty(), const PString &passwd=PString::Empty(), AuthenticationMethod authMethod=AuthSimple)
 Bind to the remote LDAP server.
PBoolean Add (const PString &dn, const PArray< ModAttrib > &attributes)
 Add a new distringuished name to LDAP dirctory.
PBoolean Add (const PString &dn, const PStringToString &attributes)
 Add a new distringuished name to LDAP dirctory.
PBoolean Add (const PString &dn, const PStringArray &attributes)
 Add a new distringuished name to LDAP dirctory.
PBoolean Add (const PString &dn, const PLDAPStructBase &data)
 Add a new distringuished name to LDAP dirctory.
PBoolean Modify (const PString &dn, const PArray< ModAttrib > &attributes)
 Modify an existing distringuished name to LDAP dirctory.
PBoolean Modify (const PString &dn, const PStringToString &attributes)
 Add a new distringuished name to LDAP dirctory.
PBoolean Modify (const PString &dn, const PStringArray &attributes)
 Add a new distringuished name to LDAP dirctory.
PBoolean Modify (const PString &dn, const PLDAPStructBase &data)
 Add a new distringuished name to LDAP dirctory.
PBoolean Delete (const PString &dn)
 Delete the distinguished name from LDAP directory.
PBoolean Search (SearchContext &context, const PString &filter, const PStringArray &attributes=PStringList(), const PString &base=PString::Empty(), SearchScope scope=ScopeSubTree)
 Start search for specified information.
PBoolean GetSearchResult (SearchContext &context, PStringToString &data)
 Get the current search result entry.
PBoolean GetSearchResult (SearchContext &context, const PString &attribute, PString &data)
 Get an attribute of the current search result entry.
PBoolean GetSearchResult (SearchContext &context, const PString &attribute, PStringArray &data)
 Get an attribute of the current search result entry.
PBoolean GetSearchResult (SearchContext &context, const PString &attribute, PArray< PBYTEArray > &data)
 Get an attribute of the current search result entry.
PBoolean GetSearchResult (SearchContext &context, PLDAPStructBase &data)
 Get all attributes of the current search result entry.
PString GetSearchResultDN (SearchContext &context)
 Get the current search result distinguished name entry.
PBoolean GetNextSearchResult (SearchContext &context)
 Get the next search result.
PList< PStringToStringSearch (const PString &filter, const PStringArray &attributes=PStringList(), const PString &base=PString::Empty(), SearchScope scope=ScopeSubTree)
 Search for specified information, returning all matches.
void SetBaseDN (const PString &dn)
 Set the default base DN for use if not specified for searches.
const PStringGetBaseDN () const
 Set the default base DN for use if not specified for searches.
int GetErrorNumber () const
 Get the last OpenLDAP error code.
PString GetErrorText () const
 Get the last OpenLDAP error as text string.
ldap * GetOpenLDAP () const
 Get the OpenLDAP context structure.
const PTimeIntervalGetTimeout () const
 Get the timeout for LDAP operations.
void SetTimeout (const PTimeInterval &t)
 Set the timeout for LDAP operations.
void SetSearchLimit (const unsigned s)
 Set a limit on the number of results to return.

Protected Attributes

ldap * ldapContext
int errorNumber
unsigned protocolVersion
PString defaultBaseDN
unsigned searchLimit
PTimeInterval timeout
PString multipleValueSeparator

Classes

class  BinaryModAttrib
class  ModAttrib
class  SearchContext
class  StringModAttrib

Detailed Description

This class will create an LDAP client to access a remote LDAP server.


Member Enumeration Documentation

enum PLDAPSession::AuthenticationMethod

Enumerator:
AuthSimple 
AuthSASL 
AuthKerberos 
NumAuthenticationMethod 

enum PLDAPSession::SearchScope

Enumerator:
ScopeBaseOnly 
ScopeSingleLevel 
ScopeSubTree 
NumSearchScope 


Constructor & Destructor Documentation

PLDAPSession::PLDAPSession ( const PString defaultBaseDN = PString::Empty()  ) 

Create a LDAP client.

PLDAPSession::~PLDAPSession (  ) 

Close the sesison on destruction.


Member Function Documentation

PBoolean PLDAPSession::Add ( const PString dn,
const PLDAPStructBase data 
)

Add a new distringuished name to LDAP dirctory.

The attributes list is a string array of the form attr=value

PBoolean PLDAPSession::Add ( const PString dn,
const PStringArray attributes 
)

Add a new distringuished name to LDAP dirctory.

The attributes list is a string array of the form attr=value

PBoolean PLDAPSession::Add ( const PString dn,
const PStringToString attributes 
)

Add a new distringuished name to LDAP dirctory.

PBoolean PLDAPSession::Add ( const PString dn,
const PArray< ModAttrib > &  attributes 
)

Add a new distringuished name to LDAP dirctory.

PBoolean PLDAPSession::Bind ( const PString who = PString::Empty(),
const PString passwd = PString::Empty(),
AuthenticationMethod  authMethod = AuthSimple 
)

Bind to the remote LDAP server.

PBoolean PLDAPSession::Close (  ) 

Close the LDAP session.

PBoolean PLDAPSession::Delete ( const PString dn  ) 

Delete the distinguished name from LDAP directory.

const PString& PLDAPSession::GetBaseDN (  )  const [inline]

Set the default base DN for use if not specified for searches.

int PLDAPSession::GetErrorNumber (  )  const [inline]

Get the last OpenLDAP error code.

PString PLDAPSession::GetErrorText (  )  const

Get the last OpenLDAP error as text string.

PBoolean PLDAPSession::GetNextSearchResult ( SearchContext context  ) 

Get the next search result.

struct ldap* PLDAPSession::GetOpenLDAP (  )  const [inline]

Get the OpenLDAP context structure.

PBoolean PLDAPSession::GetSearchResult ( SearchContext context,
PLDAPStructBase data 
)

Get all attributes of the current search result entry.

PBoolean PLDAPSession::GetSearchResult ( SearchContext context,
const PString attribute,
PArray< PBYTEArray > &  data 
)

Get an attribute of the current search result entry.

PBoolean PLDAPSession::GetSearchResult ( SearchContext context,
const PString attribute,
PStringArray data 
)

Get an attribute of the current search result entry.

PBoolean PLDAPSession::GetSearchResult ( SearchContext context,
const PString attribute,
PString data 
)

Get an attribute of the current search result entry.

PBoolean PLDAPSession::GetSearchResult ( SearchContext context,
PStringToString data 
)

Get the current search result entry.

PString PLDAPSession::GetSearchResultDN ( SearchContext context  ) 

Get the current search result distinguished name entry.

const PTimeInterval& PLDAPSession::GetTimeout (  )  const [inline]

Get the timeout for LDAP operations.

PBoolean PLDAPSession::IsOpen (  )  const [inline]

Determine of session is open.

PBoolean PLDAPSession::Modify ( const PString dn,
const PLDAPStructBase data 
)

Add a new distringuished name to LDAP dirctory.

The attributes list is a string array of the form attr=value

PBoolean PLDAPSession::Modify ( const PString dn,
const PStringArray attributes 
)

Add a new distringuished name to LDAP dirctory.

The attributes list is a string array of the form attr=value

PBoolean PLDAPSession::Modify ( const PString dn,
const PStringToString attributes 
)

Add a new distringuished name to LDAP dirctory.

PBoolean PLDAPSession::Modify ( const PString dn,
const PArray< ModAttrib > &  attributes 
)

Modify an existing distringuished name to LDAP dirctory.

PBoolean PLDAPSession::Open ( const PString server,
WORD  port = 0 
)

Open the LDAP session to the specified server.

The server name string is of the form hostip[:port] where hostip is a host name or IP address and the :port is an optional port number. If not present then the port variable is used. If that is also zero then the default port of 369 is used.

PList<PStringToString> PLDAPSession::Search ( const PString filter,
const PStringArray attributes = PStringList(),
const PString base = PString::Empty(),
SearchScope  scope = ScopeSubTree 
)

Search for specified information, returning all matches.

This can be used for simple LDAP databases where all attributes are represented by a string.

PBoolean PLDAPSession::Search ( SearchContext context,
const PString filter,
const PStringArray attributes = PStringList(),
const PString base = PString::Empty(),
SearchScope  scope = ScopeSubTree 
)

Start search for specified information.

void PLDAPSession::SetBaseDN ( const PString dn  )  [inline]

Set the default base DN for use if not specified for searches.

PBoolean PLDAPSession::SetOption ( int  optcode,
void *  value 
)

Set LDAP option parameter (OpenLDAP specific values).

PBoolean PLDAPSession::SetOption ( int  optcode,
int  value 
)

Set LDAP option parameter (OpenLDAp specific values).

void PLDAPSession::SetSearchLimit ( const unsigned  s  )  [inline]

Set a limit on the number of results to return.

void PLDAPSession::SetTimeout ( const PTimeInterval t  )  [inline]

Set the timeout for LDAP operations.


Member Data Documentation

PString PLDAPSession::defaultBaseDN [protected]

int PLDAPSession::errorNumber [protected]

struct ldap* PLDAPSession::ldapContext [protected]

PString PLDAPSession::multipleValueSeparator [protected]

unsigned PLDAPSession::protocolVersion [protected]

unsigned PLDAPSession::searchLimit [protected]

PTimeInterval PLDAPSession::timeout [protected]


The documentation for this class was generated from the following file:
Generated on Fri Oct 14 01:44:12 2011 for PTLib by  doxygen 1.4.7