DirectoryConnection
API reference › LDAP › DirectoryConnection
Binds the exact supplied credentials on a LdapRecord transport without dispatching authentication events.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
bind() | Binds a service account without transforming its password or allowing anonymous fallback. | DirectoryConnection |
bindResultCode() | Returns the LDAP result code without interpreting account or server diagnostics. | DirectoryConnection |
connect() | Opens a new handle after discarding the previous one, so its TLS state never carries over. | DirectoryConnection |
setOption() | Refuses to continue an operation if its requested server controls cannot be installed. | DirectoryConnection |
Method details
Section titled “Method details”bind()
Section titled “bind() ”public function bind(string|null $dn = null, string|null $password = null, array<array-key, mixed>|null $controls = null): LdapRecord\LdapResultResponseBinds a service account without transforming its password or allowing anonymous fallback.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dn | string| | Service-account bind name. A missing or empty name is rejected. |
$password | string| | Exact password supplied for the bind. A missing or empty password is rejected. |
$controls | array<array-key, | Optional LDAP request controls. |
Returns
LdapRecord\LdapResultResponse: Parsed bind response after validation.
Throws
DirectoryUnavailableException: If the transport is not secure or the bind cannot be performed.
bindResultCode()
Section titled “bindResultCode() ”public function bindResultCode(string $principal, string $password): intReturns the LDAP result code without interpreting account or server diagnostics.
Parameters
| Parameter | Type | Description |
|---|---|---|
$principal | string | Directory bind name. |
$password | string | Password to submit unchanged. |
Returns
int: LDAP result code; empty or NUL-containing credentials are treated as invalid credentials (49).
Throws
DirectoryUnavailableException: when StartTLS has not completed, or the result cannot be obtained.
connect()
Section titled “connect() ”public function connect(array<array-key, mixed>|string $hosts = [], int $port = 389, string|null $protocol = null): boolOpens a new handle after discarding the previous one, so its TLS state never carries over.
Parameters
| Parameter | Type | Description |
|---|---|---|
$hosts | array<array-key, | Directory host or hosts. |
$port | int | Directory port. |
$protocol | string| | URI scheme prefix, or null for the transport default. |
Returns
bool: Whether a handle was allocated.
setOption()
Section titled “setOption() ”public function setOption(int $option, mixed $value): boolRefuses to continue an operation if its requested server controls cannot be installed.
Parameters
| Parameter | Type | Description |
|---|---|---|
$option | int | LDAP option identifier. |
$value | mixed | Value accepted by that LDAP option. |
Returns
bool: Whether the option was set.
Throws
DirectoryUnavailableException: when the LDAP client rejects the server controls.