PasswordVerifier
API reference › LDAP › PasswordVerifier
Verifies credentials for an existing application’s directory identity without creating a Yii session.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$host | string | Directory hostname matching the server certificate, without a scheme or port. Default: ''. | PasswordVerifier |
$port | int | LDAP port accepting StartTLS, not an implicit TLS port. Default: 389. | PasswordVerifier |
$timeout | int | Seconds allowed for the network connection and for each directory reply. Default: 5. | PasswordVerifier |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
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() protected | Creates an unconnected transport for one verification attempt. | PasswordVerifier |
Method details
Section titled “Method details”init()
Section titled “init() ”public function init(): voidValidates the endpoint and timeout without opening a connection.
Throws
yii\base\InvalidConfigException: when the endpoint or timeout is invalid.
verify()
Section titled “verify() ”public function verify(string $principal, string $password): boolChecks 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
| Parameter | Type | Description |
|---|---|---|
$principal | string | Bind name resolved from the application’s trusted identity mapping. |
$password | string | Password submitted by the user. |
Returns
bool: Whether the directory accepted the credentials.
Throws
DirectoryUnavailableException: when the connection cannot be secured or the directory fails.
newConnection()
Section titled “newConnection() ”protected function newConnection(): yii2\extensions\ldap\DirectoryConnectionCreates an unconnected transport for one verification attempt.
Returns
DirectoryConnection: Transport with no open LDAP handle.