Skip to content
PHP Ecosystem
Explore

PasswordVerifier

API reference › LDAP › PasswordVerifier

classyii2\extensions\ldap\PasswordVerifier
Extendsyii\base\BaseObject
Implementsyii\base\Configurable
Sourcesrc/PasswordVerifier.php

Verifies credentials for an existing application’s directory identity without creating a Yii session.

PropertyTypeDescriptionDefined by
$hoststringDirectory hostname matching the server certificate, without a scheme or port. Default: ''.PasswordVerifier
$portintLDAP port accepting StartTLS, not an implicit TLS port. Default: 389.PasswordVerifier
$timeoutintSeconds allowed for the network connection and for each directory reply. Default: 5.PasswordVerifier
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\BaseObject
__get()Returns the value of an object property.yii\base\BaseObject
__isset()Checks if a property is set, i.e. defined and not null.yii\base\BaseObject
__set()Sets value of an object property.yii\base\BaseObject
__unset()Sets an object property to null.yii\base\BaseObject
canGetProperty()Returns a value indicating whether a property can be read.yii\base\BaseObject
canSetProperty()Returns a value indicating whether a property can be set.yii\base\BaseObject
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
hasMethod()Returns a value indicating whether a method is defined.yii\base\BaseObject
hasProperty()Returns a value indicating whether a property is defined.yii\base\BaseObject
init()Validates the endpoint and timeout without opening a connection.PasswordVerifier
verify()Checks the password against a principal obtained from the application’s trusted identity mapping.PasswordVerifier
newConnection() protectedCreates an unconnected transport for one verification attempt.PasswordVerifier
public function init(): void

Validates the endpoint and timeout without opening a connection.

Throws

public function verify(string $principal, string $password): bool

Checks the password against a principal obtained from the application’s trusted identity mapping.

Returns false for missing credentials, NUL bytes, or a rejected password. Each attempt owns its connection, even in a persistent worker. No directory error or submitted credential is included in exception messages.

Parameters

ParameterTypeDescription
$principalstringBind name resolved from the application’s trusted identity mapping.
$passwordstringPassword submitted by the user.

Returns

bool: Whether the directory accepted the credentials.

Throws

protected function newConnection(): yii2\extensions\ldap\DirectoryConnection

Creates an unconnected transport for one verification attempt.

Returns

DirectoryConnection: Transport with no open LDAP handle.