LdapTools\LdapManager::authenticate PHP Method

authenticate() public method

A shorthand method for verifying a username/password combination against LDAP. Optionally you can pass a variable to store the error message or error number returned from LDAP for more detailed information on authentication failures.
public authenticate ( string $user, string $password, boolean | string &$errorMessage = false, boolean | string &$errorNumber = false ) : boolean
$user string
$password string
$errorMessage boolean | string Optionally, this will store the LDAP error message on failure.
$errorNumber boolean | string Optionally, this will store the LDAP error number on failure.
return boolean
    public function authenticate($user, $password, &$errorMessage = false, &$errorNumber = false)
    {
        $operation = new AuthenticationOperation($user, $password);
        /** @var AuthenticationResponse $response */
        $response = $this->getConnection()->execute($operation);
        if ($errorMessage !== false) {
            $errorMessage = $response->getErrorMessage();
        }
        if ($errorNumber !== false) {
            $errorNumber = $response->getErrorCode();
        }
        return $response->isAuthenticated();
    }