PHP Class Scalr\Net\Ldap\LdapClient

Since: 06.06.2013
Author: Vitaliy Demidov ([email protected])
Show file Open project: scalr/scalr Class Usage Examples

Public Methods

Method Description
__construct ( Scalr\Net\Ldap\LdapConfig $config, string $username, string $password, $uid = null ) Constructor
__destruct ( ) Destructor
__sleep ( )
__wakeup ( )
clearLog ( ) Clears log
escape ( string $string ) : string Escapes query string
getConfig ( ) : Scalr\Net\Ldap\LdapConfig Gets LdapConfig
getEmail ( ) : string Gets the user email
getFullName ( ) : string Gets the user's full name
getGroupsDetails ( array $groups ) : array Retrieves information (for now only displayname/description) about groups from LDAP
getLdapError ( ) : string Gets last LDAP error
getLog ( ) : string Gets log
getUserGroups ( ) : array Gets the list of the groups in which specified user has memberships.
getUsername ( ) : string Gets username
isValidUser ( ) : boolean Checks is this user can be authenticated to LDAP
isValidUsername ( ) : boolean Checks if the username exists in the LDAP
realEscape ( string $string ) : string Escapes query string including asterisk and parentheses
unbind ( ) : boolean Unbinds LDAP connection

Protected Methods

Method Description
bindRdn ( string $username = null, string $password = null ) : boolean Binds to the LDAP directory with specified RDN and password.
getConnection ( ) : resource Gets LDAP connection link identifier
log ( string $format, mixed $args = null, mixed $_ = null ) Adds formatted string to log output

Method Details

__construct() public method

Constructor
public __construct ( Scalr\Net\Ldap\LdapConfig $config, string $username, string $password, $uid = null )
$config Scalr\Net\Ldap\LdapConfig LDAP config
$username string LDAP rdn to check. It should look like [email protected]
$password string LDAP password for the specified user

__destruct() public method

Destructor
public __destruct ( )

__sleep() public method

public __sleep ( )

__wakeup() public method

public __wakeup ( )

bindRdn() protected method

Binds to the LDAP directory with specified RDN and password.
protected bindRdn ( string $username = null, string $password = null ) : boolean
$username string RDN
$password string Password
return boolean Returns TRUE on success or FALSE otherwise

clearLog() public method

Clears log
public clearLog ( )

escape() public static method

Escapes query string
public static escape ( string $string ) : string
$string string The query string
return string

getConfig() public method

Gets LdapConfig
public getConfig ( ) : Scalr\Net\Ldap\LdapConfig
return Scalr\Net\Ldap\LdapConfig Returns LdapConfig instance

getConnection() protected method

Gets LDAP connection link identifier
protected getConnection ( ) : resource
return resource Returns LDAP connection link edentifier

getEmail() public method

Gets the user email
public getEmail ( ) : string
return string Returns user email address

getFullName() public method

Gets the user's full name
public getFullName ( ) : string
return string Returns user's full name

getGroupsDetails() public method

Retrieves information (for now only displayname/description) about groups from LDAP
public getGroupsDetails ( array $groups ) : array
$groups array List of group ids
return array Returns array of groups with their description

getLdapError() public method

Gets last LDAP error
public getLdapError ( ) : string
return string

getLog() public method

Gets log
public getLog ( ) : string
return string Returns the log output

getUserGroups() public method

Gets the list of the groups in which specified user has memberships.
public getUserGroups ( ) : array
return array Returns array of the sAMAccount name of the Groups

getUsername() public method

Gets username
public getUsername ( ) : string
return string Returns username which should look like [email protected]

isValidUser() public method

Checks is this user can be authenticated to LDAP
public isValidUser ( ) : boolean
return boolean Returns true on success or false otherwise

isValidUsername() public method

Checks if the username exists in the LDAP
public isValidUsername ( ) : boolean
return boolean Returns true on success or false if user does not exist

log() protected method

Adds formatted string to log output
protected log ( string $format, mixed $args = null, mixed $_ = null )
$format string format string. see sprintf rules
$args mixed optional argument 1
$_ mixed optional argument list

realEscape() public static method

Escapes query string including asterisk and parentheses
public static realEscape ( string $string ) : string
$string string The query string
return string

unbind() public method

Unbinds LDAP connection
public unbind ( ) : boolean
return boolean