PHP Class LdapTools\LdapManager

Author: Chad Sikorra ([email protected])
Show file Open project: ldaptools/ldaptools Class Usage Examples

Protected Properties

Property Type Description
$cache LdapTools\Cache\CacheInterface
$config The main configuration for the library.
$connections An array of "domain name" => "LdapConnection" pairs.
$context The current domain in focus for calls to this class.
$domains An array of "domain name" => "DomainConfiguration" pairs.
$ldapObjectManager LdapTools\Object\LdapObjectManager[]
$schemaFactory LdapTools\Factory\LdapObjectSchemaFactory
$schemaParser LdapTools\Schema\Parser\SchemaParserInterface

Public Methods

Method Description
__construct ( Configuration $config, variadic $connections )
addConnection ( variadic $connections ) Explicitly add connections using already constructed connection objects.
authenticate ( string $user, string $password, boolean | string &$errorMessage = false, boolean | string &$errorNumber = false ) : boolean A shorthand method for verifying a username/password combination against LDAP. Optionally you can pass a variable to store the error message or error number returned from LDAP for more detailed information on authentication failures.
buildLdapQuery ( ) : LdapQueryBuilder Get a LdapQueryBuilder object.
createLdapObject ( string | null $type = null ) : LdapObjectCreator Get a LdapObjectCreator object.
createLdif ( ) : Ldif Get a LDIF object to help build a LDIF file.
delete ( LdapObject $ldapObject, boolean $recursively = false ) Delete an object from LDAP. Optionally you can set the second argument to true which sends a control to LDAP to perform a recursive deletion. This is helpful in the case of deleting an OU with with objects underneath it. By setting the second parameter to true the OU and all objects below it would be deleted. Use with care!
getCache ( ) : LdapTools\Cache\CacheInterface Retrieve the cache instance.
getConnection ( null | string $domain = null ) : LdapTools\Connection\LdapConnectionInterface Get the Ldap Connection object. By default it will get the connection of the domain currently in context. To get a different domain connection pass the domain name as a parameter.
getDomainContext ( ) : string Get the domain name currently being used.
getDomains ( ) : string[] Get all of the domain names that are loaded.
getEventDispatcher ( ) : LdapTools\Event\EventDispatcherInterface | null Get the event dispatcher instance.
getRepository ( string $type ) : LdapObjectRepository Get a repository for a specific LDAP object type.
getSchemaFactory ( ) : LdapObjectSchemaFactory Retrieve the schema factory instance.
getSchemaParser ( ) : LdapTools\Schema\Parser\SchemaParserInterface Retrieve the schema parser instance.
move ( LdapObject $ldapObject, string $container ) Move an object in LDAP from one container/OU to another.
persist ( LdapObject $ldapObject ) Sends a LdapObject back to LDAP so the changes can be written to the directory.
restore ( LdapObject $ldapObject, string | null $container = null ) Restore a deleted LDAP object. Optionally specify where to restore it to (full DN of a container/OU).
switchDomain ( string $domain ) Switch the context of the LdapManager by passing a domain name (ie. 'example.local').

Protected Methods

Method Description
getLdapObjectSchema ( string $type ) : LdapObjectSchema Get the LDAP object schema from the factory by its type.
getObjectManager ( ) : LdapObjectManager Retrieve the LdapObjectManager for the current domain context.
registerAttributeConverters ( array $attributeConverters ) Register any explicitly defined converters.
validateDomainName ( string $domain ) Validates that the domain name actually exists.

Method Details

__construct() public method

public __construct ( Configuration $config, variadic $connections )
$config Configuration
$connections variadic

addConnection() public method

Explicitly add connections using already constructed connection objects.
public addConnection ( variadic $connections )
$connections variadic

authenticate() public method

A shorthand method for verifying a username/password combination against LDAP. Optionally you can pass a variable to store the error message or error number returned from LDAP for more detailed information on authentication failures.
public authenticate ( string $user, string $password, boolean | string &$errorMessage = false, boolean | string &$errorNumber = false ) : boolean
$user string
$password string
$errorMessage boolean | string Optionally, this will store the LDAP error message on failure.
$errorNumber boolean | string Optionally, this will store the LDAP error number on failure.
return boolean

buildLdapQuery() public method

Get a LdapQueryBuilder object.
public buildLdapQuery ( ) : LdapQueryBuilder
return LdapTools\Query\LdapQueryBuilder

createLdapObject() public method

Get a LdapObjectCreator object.
public createLdapObject ( string | null $type = null ) : LdapObjectCreator
$type string | null
return LdapTools\Object\LdapObjectCreator

createLdif() public method

Get a LDIF object to help build a LDIF file.
public createLdif ( ) : Ldif
return LdapTools\Ldif\Ldif

delete() public method

If recursive deletion does not work, first check that 'accidental deletion' is not enabled on the object (AD).
public delete ( LdapObject $ldapObject, boolean $recursively = false )
$ldapObject LdapTools\Object\LdapObject
$recursively boolean

getCache() public method

Retrieve the cache instance.
public getCache ( ) : LdapTools\Cache\CacheInterface
return LdapTools\Cache\CacheInterface

getConnection() public method

Get the Ldap Connection object. By default it will get the connection of the domain currently in context. To get a different domain connection pass the domain name as a parameter.
public getConnection ( null | string $domain = null ) : LdapTools\Connection\LdapConnectionInterface
$domain null | string
return LdapTools\Connection\LdapConnectionInterface

getDomainContext() public method

Get the domain name currently being used.
public getDomainContext ( ) : string
return string

getDomains() public method

Get all of the domain names that are loaded.
public getDomains ( ) : string[]
return string[]

getEventDispatcher() public method

Get the event dispatcher instance.
public getEventDispatcher ( ) : LdapTools\Event\EventDispatcherInterface | null
return LdapTools\Event\EventDispatcherInterface | null

getLdapObjectSchema() protected method

Get the LDAP object schema from the factory by its type.
protected getLdapObjectSchema ( string $type ) : LdapObjectSchema
$type string
return LdapTools\Schema\LdapObjectSchema

getObjectManager() protected method

Retrieve the LdapObjectManager for the current domain context.
protected getObjectManager ( ) : LdapObjectManager
return LdapTools\Object\LdapObjectManager

getRepository() public method

Get a repository for a specific LDAP object type.
public getRepository ( string $type ) : LdapObjectRepository
$type string
return LdapTools\Object\LdapObjectRepository

getSchemaFactory() public method

Retrieve the schema factory instance.
public getSchemaFactory ( ) : LdapObjectSchemaFactory
return LdapTools\Factory\LdapObjectSchemaFactory

getSchemaParser() public method

Retrieve the schema parser instance.
public getSchemaParser ( ) : LdapTools\Schema\Parser\SchemaParserInterface
return LdapTools\Schema\Parser\SchemaParserInterface

move() public method

Move an object in LDAP from one container/OU to another.
public move ( LdapObject $ldapObject, string $container )
$ldapObject LdapTools\Object\LdapObject
$container string The container/OU in DN format.

persist() public method

Sends a LdapObject back to LDAP so the changes can be written to the directory.
public persist ( LdapObject $ldapObject )
$ldapObject LdapTools\Object\LdapObject

registerAttributeConverters() protected method

Register any explicitly defined converters.
protected registerAttributeConverters ( array $attributeConverters )
$attributeConverters array

restore() public method

Restore a deleted LDAP object. Optionally specify where to restore it to (full DN of a container/OU).
public restore ( LdapObject $ldapObject, string | null $container = null )
$ldapObject LdapTools\Object\LdapObject
$container string | null The container/OU in DN format of where it should be restored to.

switchDomain() public method

Switch the context of the LdapManager by passing a domain name (ie. 'example.local').
public switchDomain ( string $domain )
$domain string

validateDomainName() protected method

Validates that the domain name actually exists.
protected validateDomainName ( string $domain )
$domain string

Property Details

$cache protected property

protected CacheInterface,LdapTools\Cache $cache
return LdapTools\Cache\CacheInterface

$config protected property

The main configuration for the library.
protected $config

$connections protected property

An array of "domain name" => "LdapConnection" pairs.
protected $connections

$context protected property

The current domain in focus for calls to this class.
protected $context

$domains protected property

An array of "domain name" => "DomainConfiguration" pairs.
protected $domains

$ldapObjectManager protected property

protected LdapObjectManager[],LdapTools\Object $ldapObjectManager
return LdapTools\Object\LdapObjectManager[]

$schemaFactory protected property

protected LdapObjectSchemaFactory,LdapTools\Factory $schemaFactory
return LdapTools\Factory\LdapObjectSchemaFactory

$schemaParser protected property

protected SchemaParserInterface,LdapTools\Schema\Parser $schemaParser
return LdapTools\Schema\Parser\SchemaParserInterface