You are here

private function LoginValidator::testUserPassword in Lightweight Directory Access Protocol (LDAP) 8.3

Tests the user's password.

Return value

bool Valid login.

1 call to LoginValidator::testUserPassword()
LoginValidator::testCredentials in ldap_authentication/src/Controller/LoginValidator.php
Credentials are tested.

File

ldap_authentication/src/Controller/LoginValidator.php, line 396

Class

LoginValidator
Handles the actual testing of credentials and authentication of users.

Namespace

Drupal\ldap_authentication\Controller

Code

private function testUserPassword($password) {
  $loginValid = FALSE;
  if ($this->serverDrupalUser
    ->get('bind_method') == 'user') {
    $loginValid = TRUE;
  }
  else {
    CredentialsStorage::storeUserDn($this->ldapUser['dn']);
    CredentialsStorage::testCredentials(TRUE);
    $bindResult = $this->serverDrupalUser
      ->bind();
    CredentialsStorage::testCredentials(FALSE);
    if ($bindResult == Server::LDAP_SUCCESS) {
      $loginValid = TRUE;
    }
    else {
      $this->detailLog
        ->log('%username: Error testing user credentials on server %id with %bind_method. Error: %err_text', [
        '%username' => $this->authName,
        '%bind_method' => $this->serverDrupalUser
          ->getFormattedBind(),
        '%id' => $this->serverDrupalUser
          ->id(),
        '%err_text' => $this->serverDrupalUser
          ->formattedError($bindResult),
      ], 'ldap_authentication');
    }
  }
  return $loginValid;
}