You are here

function ldap_authentication_show_reset_pwd in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_authentication/ldap_authentication.module \ldap_authentication_show_reset_pwd()
  2. 7.2 ldap_authentication/ldap_authentication.module \ldap_authentication_show_reset_pwd()
2 calls to ldap_authentication_show_reset_pwd()
_ldap_authentication_form_user_profile_form_alter in ldap_authentication/ldap_authentication.inc
_ldap_authentication_login_form_alter in ldap_authentication/ldap_authentication.inc
helper function for ldap_authn_form_user_login_block_alter and ldap_authn_form_user_login_alter
1 string reference to 'ldap_authentication_show_reset_pwd'
ldap_authentication_menu_alter in ldap_authentication/ldap_authentication.module
Implements hook_menu_alter(). since menu items are cached, only useful to add or alter callbacks for ldap authentication driven menu items.

File

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

Code

function ldap_authentication_show_reset_pwd($user = NULL) {
  if (!$user) {
    global $user;
  }
  $auth_conf = ldap_authentication_get_valid_conf();
  if (current_path() == 'user/password' || $user->uid == 1 || !$auth_conf) {
    return TRUE;

    // always show at user/passwordurl. otherwise user 1 will not be able to reset password.
    // LDAP_authen.login_forms.MM.user1, LDAP_authen.login_forms.EM.user1
  }
  if ($user->uid == 0) {

    // hide reset password for anonymous users if ldap only authentication, otherwise show
    // LDAP_authen.login_forms.MM.anon, LDAP_authen.login_forms.EM.anon
    return $auth_conf->authenticationMode != LDAP_AUTHENTICATION_EXCLUSIVE;
  }
  else {

    // authenticated user.  hide if ldap authenticated otherwise show.
    // LDAP_authen.login_forms.EM.ldap, LDAP_authen.login_forms.EM.drupal,
    // LDAP_authen.login_forms.MM.drupal, LDAP_authen.login_forms.MM.ldap
    return !ldap_authentication_ldap_authenticated($user);
  }
}