function ldap_user_form_register_form_submit2 in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_user/ldap_user.module \ldap_user_form_register_form_submit2()
- 8.2 ldap_user/ldap_user.module \ldap_user_form_register_form_submit2()
- 7.2 ldap_user/ldap_user.module \ldap_user_form_register_form_submit2()
Called after user_register_form_submit.
1 string reference to 'ldap_user_form_register_form_submit2'
- ldap_user_form_user_register_form_alter in ldap_user/
ldap_user.module - Implements hook_form_FORM_ID_alter().
File
- ldap_user/
ldap_user.module, line 358 - Module for the LDAP User Entity.
Code
function ldap_user_form_register_form_submit2(&$form, FormState $form_state) {
// It's only called when a user who can create a new user does so using the
// register form.
$values = $form_state
->getValues();
$ldap_user_association_set = FALSE;
// Create LDAP account.
if ($values['ldap_user_create_ldap_acct']) {
if ($account = user_load_by_name($values['name'])) {
$ldapProcessor = new LdapUserProcessor();
// We check that the entry does not exist, validation should prevent this
// in nearly all cases.
$ldap_provision_entry = $ldapProcessor
->getProvisionRelatedLdapEntry($account);
if (!$ldap_provision_entry) {
$provision_result = $ldapProcessor
->provisionLdapEntry($account);
if ($provision_result['status'] == 'fail') {
drupal_set_message(t('An error occurred while creating your LDAP entry, please see the log for details.'), 'error');
}
}
else {
// Fallback for collisions in registration process.
$ldap_user_association_set = TRUE;
}
}
}
$userProcessor = new DrupalUserProcessor();
if ($values['ldap_user_association'] == LdapUserAttributesInterface::MANUAL_ACCOUNT_CONFLICT_NO_LDAP_ASSOCIATE) {
$userProcessor
->ldapExcludeDrupalAccount($values['name']);
}
elseif ($ldap_user_association_set || $values['ldap_user_association'] == LdapUserAttributesInterface::MANUAL_ACCOUNT_CONFLICT_LDAP_ASSOCIATE) {
// Either LDAP provision (above) has said "associate" or the person creating
// the account has said "associate" or the LDAP user settings says
// "Associate manually created Drupal accounts with related LDAP Account
// if one exists.".
$association = $userProcessor
->ldapAssociateDrupalAccount($values['name']);
if (!$association) {
drupal_set_message(t('Account created but no LDAP account found to associate with.'), 'warning');
}
}
}