private function DrupalUserProcessor::setFieldsOnDrupalUserCreation in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 ldap_user/src/Processor/DrupalUserProcessor.php \Drupal\ldap_user\Processor\DrupalUserProcessor::setFieldsOnDrupalUserCreation()
Sets the fields for initial users.
1 call to DrupalUserProcessor::setFieldsOnDrupalUserCreation()
- DrupalUserProcessor::applyAttributesToAccountOnCreate in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Apply field values to user account.
File
- ldap_user/
src/ Processor/ DrupalUserProcessor.php, line 681
Class
- DrupalUserProcessor
- Handles processing of a user from LDAP to Drupal.
Namespace
Drupal\ldap_user\ProcessorCode
private function setFieldsOnDrupalUserCreation() : void {
$derived_mail = $this->server
->deriveEmailFromLdapResponse($this->ldapEntry);
if (!$this->account
->getEmail()) {
$this->account
->set('mail', $derived_mail);
}
if (!$this->account
->getPassword()) {
if (version_compare(\Drupal::VERSION, '9.1', '>=')) {
// phpcs:ignore
$this->account
->set('pass', \Drupal::service('password_generator')
->generate(20));
}
else {
$this->account
->set('pass', user_password(20));
}
}
if (!$this->account
->getInitialEmail()) {
$this->account
->set('init', $derived_mail);
}
if (!$this->account
->isBlocked()) {
$this->account
->set('status', 1);
}
}