You are here

private function DrupalUserProcessor::setFieldsOnDrupalUserCreation in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_user/src/Processor/DrupalUserProcessor.php \Drupal\ldap_user\Processor\DrupalUserProcessor::setFieldsOnDrupalUserCreation()

Sets the fields for initial users.

Parameters

array $ldapUser: Ldap user data.

1 call to DrupalUserProcessor::setFieldsOnDrupalUserCreation()
DrupalUserProcessor::applyAttributesToAccount in ldap_user/src/Processor/DrupalUserProcessor.php
Apply field values to user account.

File

ldap_user/src/Processor/DrupalUserProcessor.php, line 1069

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function setFieldsOnDrupalUserCreation(array $ldapUser) {
  $derived_mail = $this->server
    ->userEmailFromLdapEntry($ldapUser['attr']);
  if (!$this->account
    ->getEmail()) {
    $this->account
      ->set('mail', $derived_mail);
  }
  if (!$this->account
    ->getPassword()) {
    $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);
  }
}