function ldap_user_form_register_form_validate in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 8.4 ldap_user/ldap_user.module \ldap_user_form_register_form_validate()
- 8.3 ldap_user/ldap_user.module \ldap_user_form_register_form_validate()
- 7.2 ldap_user/ldap_user.module \ldap_user_form_register_form_validate()
1 string reference to 'ldap_user_form_register_form_validate'
- ldap_user_form_user_register_form_alter in ldap_user/
ldap_user.module - Implements hook_form_FORM_ID_alter(). for user_register_form
File
- ldap_user/
ldap_user.module, line 563 - Module for the LDAP User Entity
Code
function ldap_user_form_register_form_validate($form, &$form_state) {
$values = $form_state['values'];
$user_ldap_entry = NULL;
$drupal_username = $form_state['values']['name'];
if ($values['ldap_user_association'] == LDAP_USER_MANUAL_ACCT_CONFLICT_NO_LDAP_ASSOCIATE) {
$form_state['values']['ldap_user_ldap_exclude']['und'][0]['value'] = 1;
}
// if corresponding ldap account doesn't exist and provision not selected and make ldap associated is selected, throw error
if (!@$values['ldap_user_create_ldap_acct'] && @$values['ldap_user_association'] == LDAP_USER_MANUAL_ACCT_CONFLICT_LDAP_ASSOCIATE) {
$ldap_user_conf = ldap_user_conf();
$ldap_user = ldap_servers_get_user_ldap_data($drupal_username, $ldap_user_conf->ldapEntryProvisionServer, 'ldap_user_prov_to_drupal');
if (!$ldap_user) {
form_set_error('ldap_user_association', t('User %name does not have a corresponding LDAP Entry (dn).
Under LDAP options, you may NOT select "Make this an LDAP Associated Account"', array(
'%name' => $drupal_username,
)));
}
}
// if trying to provision and ldap account and one already exists, throw error.
if (@$values['ldap_user_create_ldap_acct']) {
$ldap_user_conf = ldap_user_conf();
$ldap_user = ldap_servers_get_user_ldap_data($drupal_username, $ldap_user_conf->ldapEntryProvisionServer, 'ldap_user_prov_to_ldap');
if ($ldap_user) {
$tokens = array(
'%dn' => $ldap_user['dn'],
'%name' => $drupal_username,
);
form_set_error('ldap_user_create_ldap_acct', t('User %name already has a corresponding LDAP Entry (%dn).
Uncheck "Create corresponding LDAP entry" to allow this Drupal user to be created. Select
"Make this an LDAP associated account" to associate this account with the ldap entry.', $tokens));
}
}
}