You are here

private function DrupalUserProcessor::setLdapBaseFields in Lightweight Directory Access Protocol (LDAP) 8.4

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

Sets the fields required by LDAP.

Parameters

string $event: Provisioning event.

2 calls to DrupalUserProcessor::setLdapBaseFields()
DrupalUserProcessor::applyAttributesToAccount in ldap_user/src/Processor/DrupalUserProcessor.php
Apply field values to user account.
DrupalUserProcessor::applyAttributesToAccountOnCreate in ldap_user/src/Processor/DrupalUserProcessor.php
Apply field values to user account.

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function setLdapBaseFields(string $event) : void {

  // Basic $user LDAP fields.
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[property.name]', $event)) {
    $this->account
      ->set('name', $this->server
      ->deriveUsernameFromLdapResponse($this->ldapEntry));
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[property.mail]', $event)) {
    $derived_mail = $this->server
      ->deriveEmailFromLdapResponse($this->ldapEntry);
    if (!empty($derived_mail)) {
      $this->account
        ->set('mail', $derived_mail);
    }
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[property.picture]', $event)) {
    $picture = $this
      ->userPictureFromLdapEntry();
    if ($picture) {
      $this->account
        ->set('user_picture', $picture);
    }
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[field.ldap_user_puid]', $event)) {
    $ldap_user_puid = $this->server
      ->derivePuidFromLdapResponse($this->ldapEntry);
    if (!empty($ldap_user_puid)) {
      $this->account
        ->set('ldap_user_puid', $ldap_user_puid);
    }
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[field.ldap_user_puid_property]', $event)) {
    $this->account
      ->set('ldap_user_puid_property', $this->server
      ->getUniquePersistentAttribute());
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[field.ldap_user_puid_sid]', $event)) {
    $this->account
      ->set('ldap_user_puid_sid', $this->server
      ->id());
  }
  if ($this->fieldProvider
    ->attributeIsSyncedOnEvent('[field.ldap_user_current_dn]', $event)) {
    $this->account
      ->set('ldap_user_current_dn', $this->ldapEntry
      ->getDn());
  }
}