You are here

public function DrupalUserProcessor::excludeUser in Lightweight Directory Access Protocol (LDAP) 8.4

Check if user is excluded.

Parameters

\Drupal\user\UserInterface $account: A Drupal user object.

Return value

bool TRUE if user should be excluded from LDAP provision/syncing

2 calls to DrupalUserProcessor::excludeUser()
DrupalUserProcessor::drupalUserLogsIn in ldap_user/src/Processor/DrupalUserProcessor.php
Handle Drupal user login.
DrupalUserProcessor::drupalUserUpdate in ldap_user/src/Processor/DrupalUserProcessor.php
Callback for hook_ENTITY_TYPE_update().

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

public function excludeUser(UserInterface $account) : bool {
  if ($this->configAuthentication
    ->get('skipAdministrators')) {
    $admin_roles = $this->entityTypeManager
      ->getStorage('user_role')
      ->getQuery()
      ->condition('is_admin', TRUE)
      ->execute();
    if (!empty(array_intersect($account
      ->getRoles(), $admin_roles))) {
      return TRUE;
    }
  }

  // Exclude users who have been manually flagged as excluded, everyone else
  // is fine.
  return $account
    ->get('ldap_user_ldap_exclude')
    ->getString() === '1';
}