You are here

public function SyncMappingHelper::getLdapUserRequiredAttributes in Lightweight Directory Access Protocol (LDAP) 8.3

Util to fetch attributes required for this user conf, not other modules.

Parameters

int $direction: LDAP_USER_PROV_DIRECTION_* constants.

string $ldap_context: LDAP context.

Return value

array Required attributes.

File

ldap_user/src/Helper/SyncMappingHelper.php, line 225

Class

SyncMappingHelper
Helper class to process user field synchronisation mappings.

Namespace

Drupal\ldap_user\Helper

Code

public function getLdapUserRequiredAttributes($direction = NULL, $ldap_context = NULL) {
  if ($direction == NULL) {
    $direction = self::PROVISION_TO_ALL;
  }
  $required_attributes = [];
  if ($this->config
    ->get('drupalAcctProvisionServer')) {
    $prov_events = $this
      ->ldapContextToProvEvents($ldap_context);
    $attributes_map = $this
      ->getSyncMappings($direction, $prov_events);
    $required_attributes = [];
    foreach ($attributes_map as $detail) {
      if (count(array_intersect($prov_events, $detail['prov_events']))) {

        // Add the attribute to our array.
        if ($detail['ldap_attr']) {
          ConversionHelper::extractTokenAttributes($required_attributes, $detail['ldap_attr']);
        }
      }
    }
  }
  return $required_attributes;
}