function _ldap_authentication_login_form_alter in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.4 ldap_authentication/ldap_authentication.module \_ldap_authentication_login_form_alter()
- 8.2 ldap_authentication/ldap_authentication.inc \_ldap_authentication_login_form_alter()
- 8.3 ldap_authentication/ldap_authentication.module \_ldap_authentication_login_form_alter()
- 7 ldap_authentication/ldap_authentication.inc \_ldap_authentication_login_form_alter()
Helper function for ldap_authn_form_user_login_block_alter and ldap_authn_form_user_login_alter.
@todo if form is being generated on non https and is set in preferences, set warning and end form development
2 calls to _ldap_authentication_login_form_alter()
- ldap_authentication_form_user_login_alter in ldap_authentication/
ldap_authentication.module - Implements hook_form_FORM_ID_alter(). for user_login.
- ldap_authentication_form_user_login_block_alter in ldap_authentication/
ldap_authentication.module - Implements hook_form_FORM_ID_alter(). for user_login_block.
File
- ldap_authentication/
ldap_authentication.inc, line 13 - Ldap_authentication helper functions.
Code
function _ldap_authentication_login_form_alter(&$form, &$form_state, $form_id) {
if (!($auth_conf = ldap_authentication_get_valid_conf())) {
return;
}
elseif (!$auth_conf
->hasEnabledAuthenticationServers()) {
return;
}
/**
*
* add validate function to test for ldap authentication
* should be placed after user_login_authenticate_validate
* 1. user_login_name_validate
* 2. user_login_authenticate_validate
* 3. external authentication validate functions
* 4. user_login_final_validate
*
* as articulated above user_login_default_validators() in user.module
*
* without any other external authentication modules, this array will start out as:
* array('user_login_name_validate', 'user_login_authenticate_validate', 'user_login_final_validate')
*/
if (@in_array('user_login_authenticate_validate', $form['#validate']) && $auth_conf->authenticationMode) {
$key = array_search('user_login_authenticate_validate', $form['#validate']);
$form['#validate'][$key] = 'ldap_authentication_core_override_user_login_authenticate_validate';
array_splice($form['#validate'], $key + 1, 0, 'ldap_authentication_user_login_authenticate_validate');
}
if ($form_id == 'user_login_block') {
$user_register = variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
$vars = [
'show_reset_pwd' => ldap_authentication_show_reset_pwd(),
'auth_conf' => $auth_conf,
];
$form['links']['#markup'] = theme('ldap_authentication_user_login_block_links', $vars);
}
// Add help information for entering in username/password.
$auth_conf = ldap_authentication_get_valid_conf();
if ($auth_conf) {
if (isset($auth_conf->loginUIUsernameTxt)) {
$form['name']['#description'] = t($auth_conf->loginUIUsernameTxt);
}
if (isset($auth_conf->loginUIPasswordTxt)) {
$form['pass']['#description'] = t($auth_conf->loginUIPasswordTxt);
}
if ($auth_conf->templateUsageRedirectOnLogin) {
$form['#submit'][] = 'ldap_authentication_check_for_email_template';
}
}
}