function simple_ldap_user_register_form_validate in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_user/simple_ldap_user.module \simple_ldap_user_register_form_validate()
Check the name and email both belong to the same LDAP account, or no account at all.
1 string reference to 'simple_ldap_user_register_form_validate'
- simple_ldap_user_form_alter in simple_ldap_user/
simple_ldap_user.module - Implements hook_form_alter().
File
- simple_ldap_user/
simple_ldap_user.module, line 543 - Main simple_ldap_user module file.
Code
function simple_ldap_user_register_form_validate($form, &$form_state) {
$ldap_user_by_name = SimpleLdapUser::singleton($form_state['values']['name']);
$ldap_user_by_mail = SimpleLdapUser::singleton($form_state['values']['mail']);
$name_dn = $ldap_user_by_name->dn;
$mail_dn = $ldap_user_by_mail->dn;
if ($name_dn !== $mail_dn) {
if (empty($mail_dn)) {
form_set_error('name', t('A user with that username is already registered, but not with that email address.'));
}
else {
if (empty($name_dn)) {
form_set_error('mail', t('A user with that email address is already registered, but not with that user name.'));
}
else {
form_set_error('name', t('That username is already in use with a different email address.'));
}
}
}
}