You are here

function ldap_authentication_user_pass_validate in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 8.4 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
  2. 8.3 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
  3. 7.2 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
  4. 7 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
1 string reference to 'ldap_authentication_user_pass_validate'
ldap_authentication_form_user_pass_alter in ldap_authentication/ldap_authentication.module
Implements hook_form_FORM_ID_alter().

File

ldap_authentication/ldap_authentication.module, line 311
This module injects itself into Drupal's Authentication stack.

Code

function ldap_authentication_user_pass_validate(&$form_state) {
  $name_or_mail = trim($form_state['name']['#value']);
  if ($account = user_load_by_mail($name_or_mail)) {
  }
  else {
    $account = user_load_by_name($name_or_mail);
  }
  if (ldap_authentication_ldap_authenticated($account)) {
    $vars = array(
      'account' => $account,
      'auth_conf' => ldap_authentication_get_valid_conf(),
    );
    $error = TRUE;
    if (is_object($vars['auth_conf'])) {
      if ($vars['auth_conf']->passwordOption == LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW) {
        $error = FALSE;
      }
    }
    if (!empty($error)) {
      form_set_error('name', theme('ldap_authentication_user_pass_validate_ldap_authenticated', $vars));
    }
  }
}