Skip to content

[LDAP] Add error codes to exceptions #28677

@shanept

Description

@shanept

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;
        ...
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions