You are here

public function DrupalUserProcessor::isUserLdapAssociated in Lightweight Directory Access Protocol (LDAP) 8.3

Test if the user is LDAP associated.

Parameters

\Drupal\user\UserInterface $account: The Drupal user.

Return value

bool Whether the user is LDAP associated.

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

public function isUserLdapAssociated(UserInterface $account) {
  $associated = FALSE;
  if (property_exists($account, 'ldap_user_current_dn') && !empty($account
    ->get('ldap_user_current_dn')->value)) {
    $associated = TRUE;
  }
  elseif ($account
    ->id()) {
    $authmap = ExternalAuthenticationHelper::getUserIdentifierFromMap($account
      ->id());
    if (!empty($authmap)) {
      $associated = TRUE;
    }
  }
  return $associated;
}