You are here

function ldap_authentication_fail_response in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_authentication/ldap_authentication.inc \ldap_authentication_fail_response()
1 call to ldap_authentication_fail_response()
_ldap_authentication_user_login_authenticate_validate in ldap_authentication/ldap_authentication.inc
user form validation will take care of username, pwd fields this function validates ldap authentication specific

File

ldap_authentication/ldap_authentication.inc, line 583
ldap_authentication helper functions

Code

function ldap_authentication_fail_response($authentication_result, $auth_conf, $detailed_watchdog_log, &$watchdog_tokens) {
  $watchdog_tokens['%err_text'] = _ldap_authentication_err_text($authentication_result);

  // fail scenario 1.  ldap auth exclusive and failed  throw error so no other authentication methods are allowed
  if ($auth_conf->authenticationMode == LDAP_AUTHENTICATION_EXCLUSIVE) {
    if ($detailed_watchdog_log) {
      watchdog('ldap_authentication', '%username : setting error because failed at ldap and
        LDAP_AUTHENTICATION_EXCLUSIVE is set to true.  So need to stop authentication of Drupal user that is not user 1.
        error message: %err_text', $watchdog_tokens, WATCHDOG_DEBUG);
    }
    form_set_error('name', $watchdog_tokens['%err_text']);
  }
  else {

    // fail scenario 2.  simply fails ldap.  return false, but don't throw form error
    // don't show user message, may be using other authentication after this that may succeed.
    if ($detailed_watchdog_log) {
      watchdog('ldap_authentication', '%username : Failed ldap authentication.
        User may have authenticated successfully by other means in a mixed authentication site.
        LDAP Authentication Error #: %auth_result  error message: %err_text', $watchdog_tokens, WATCHDOG_DEBUG);
    }
  }
}