Closed
Description
Description
Upon LDAP errors, the PHP ldap extension may also return an error code. Using this code may provide a friendlier way to determine the root cause of an issue than to interpret the error message - consider how the following example may be achieved currently, with the LDAP component.
Example
$ldap = Ldap::create('ext_ldap', [...]);
try {
$ldap->bind('invalid_user', 'invalid_password');
} catch (ConnectionException $ex) {
switch ($ex->getCode()) {
case INVALID_CREDENTIALS:
$message = 'Invalid Username or Password.';
break;
case CONNECTION_TIMEOUT:
$message = 'Unable to connect to server.';
break;
...
}
}