You are here

private function DrupalUserProcessor::applyAttributesToAccount 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::applyAttributesToAccount()

Apply field values to user account.

One should not assume all attributes are present in the LDAP entry.

Parameters

array $ldapUser: LDAP entry.

string $direction: The provisioning direction.

array $prov_events: The provisioning events.

3 calls to DrupalUserProcessor::applyAttributesToAccount()
DrupalUserProcessor::createDrupalUser in ldap_user/src/Processor/DrupalUserProcessor.php
Create a Drupal user.
DrupalUserProcessor::loginDrupalAccountProvisioning in ldap_user/src/Processor/DrupalUserProcessor.php
Handle account login with Drupal provisioning.
DrupalUserProcessor::syncToDrupalAccount in ldap_user/src/Processor/DrupalUserProcessor.php
For a Drupal account, query LDAP, get all user fields and save.

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function applyAttributesToAccount(array $ldapUser, $direction = NULL, array $prov_events = NULL) {
  if ($direction == NULL) {
    $direction = self::PROVISION_TO_DRUPAL;
  }
  if (!$prov_events) {
    $prov_events = LdapConfiguration::getAllEvents();
  }
  $this
    ->setLdapBaseFields($ldapUser, $direction, $prov_events);
  if ($direction == self::PROVISION_TO_DRUPAL && in_array(self::EVENT_CREATE_DRUPAL_USER, $prov_events)) {

    // If empty, set initial mail, status active, generate a random password.
    $this
      ->setFieldsOnDrupalUserCreation($ldapUser);
  }
  $this
    ->setUserDefinedMappings($ldapUser, $direction, $prov_events);
  $context = [
    'ldap_server' => $this->server,
    'prov_events' => $prov_events,
  ];
  \Drupal::moduleHandler()
    ->alter('ldap_user_edit_user', $this->account, $ldapUser, $context);

  // Set ldap_user_last_checked.
  $this->account
    ->set('ldap_user_last_checked', time());
}