Skip to content
PHP Ecosystem
Explore

DirectoryConnection

API reference › LDAP › DirectoryConnection

classyii2\extensions\ldap\DirectoryConnection
ExtendsLdapRecord\Ldap
Sourcesrc/DirectoryConnection.php

Binds the exact supplied credentials on a LdapRecord transport without dispatching authentication events.

MethodDescriptionDefined 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
public function bind(string|null $dn = null, string|null $password = null, array<array-key, mixed>|null $controls = null): LdapRecord\LdapResultResponse

Binds a service account without transforming its password or allowing anonymous fallback.

Parameters

ParameterTypeDescription
$dnstring|nullService-account bind name. A missing or empty name is rejected.
$passwordstring|nullExact password supplied for the bind. A missing or empty password is rejected.
$controlsarray<array-key, mixed>|nullOptional LDAP request controls.

Returns

LdapRecord\LdapResultResponse: Parsed bind response after validation.

Throws

public function bindResultCode(string $principal, string $password): int

Returns the LDAP result code without interpreting account or server diagnostics.

Parameters

ParameterTypeDescription
$principalstringDirectory bind name.
$passwordstringPassword to submit unchanged.

Returns

int: LDAP result code; empty or NUL-containing credentials are treated as invalid credentials (49).

Throws

public function connect(array<array-key, mixed>|string $hosts = [], int $port = 389, string|null $protocol = null): bool

Opens a new handle after discarding the previous one, so its TLS state never carries over.

Parameters

ParameterTypeDescription
$hostsarray<array-key, mixed>|stringDirectory host or hosts.
$portintDirectory port.
$protocolstring|nullURI scheme prefix, or null for the transport default.

Returns

bool: Whether a handle was allocated.

public function setOption(int $option, mixed $value): bool

Refuses to continue an operation if its requested server controls cannot be installed.

Parameters

ParameterTypeDescription
$optionintLDAP option identifier.
$valuemixedValue accepted by that LDAP option.

Returns

bool: Whether the option was set.

Throws