Class ExtensionAdapter
Provides a very thin OOP wrapper around the ldap_* functions.
We don't need and want a huge LDAP lib for our purpose.
But this makes it easier to unit test code that is using LDAP because we can mock it very easy. It also provides some convenience.
Property Summary
-
$_connection protected
LDAP\Connection|null
LDAP Object
Method Summary
-
__construct() public
Constructor
-
_setErrorHandler() protected
Set an error handler to turn LDAP errors into exceptions
-
_unsetErrorHandler() protected
Restore the error handler
-
bind() public
Bind to LDAP directory
-
connect() public
Connect to an LDAP server
-
getConnection() public
Get the LDAP connection
-
getDiagnosticMessage() public
Get the diagnostic message
-
getOption() public
Get the current value for given option
-
setOption() public
Set the value of the given option
-
unbind() public
Unbind from LDAP directory
Method Detail
_setErrorHandler() ¶ protected
_setErrorHandler(): void
Set an error handler to turn LDAP errors into exceptions
Returns
void
Throws
ErrorException
bind() ¶ public
bind(string $bind, string $password): bool
Bind to LDAP directory
Parameters
-
string
$bind Bind rdn
-
string
$password Bind password
Returns
bool
connect() ¶ public
connect(string $host, int $port, array $options): void
Connect to an LDAP server
Parameters
-
string
$host Hostname
-
int
$port Port
-
array
$options Additonal LDAP options
Returns
void
getConnection() ¶ public
getConnection(): LDAP\Connection
Get the LDAP connection
Returns
LDAP\Connection
Throws
RuntimeException
If the connection is empty
getDiagnosticMessage() ¶ public
getDiagnosticMessage(): string|null
Get the diagnostic message
Returns
string|null
getOption() ¶ public
getOption(int $option): mixed
Get the current value for given option
Parameters
-
int
$option Option to get
Returns
mixed
setOption() ¶ public
setOption(int $option, mixed $value): void
Set the value of the given option
Parameters
-
int
$option Option to set
-
mixed
$value The new value for the specified option
Returns
void