You are here

protected function LoginValidatorBase::initializeDrupalUserFromAuthName in Lightweight Directory Access Protocol (LDAP) 8.4

Determine if the corresponding Drupal account exists and is mapped.

Ideally we would only ask the external authmap but are allowing matching by name, too, for association handling later.

1 call to LoginValidatorBase::initializeDrupalUserFromAuthName()
LoginValidatorBase::validateCommonLoginConstraints in ldap_authentication/src/Controller/LoginValidatorBase.php
Validate common login constraints for user.

File

ldap_authentication/src/Controller/LoginValidatorBase.php, line 283

Class

LoginValidatorBase
Handles the actual testing of credentials and authentication of users.

Namespace

Drupal\ldap_authentication\Controller

Code

protected function initializeDrupalUserFromAuthName() : void {
  $load_by_name = $this->entityTypeManager
    ->getStorage('user')
    ->loadByProperties([
    'name' => $this->authName,
  ]);
  $this->drupalUser = $load_by_name ? reset($load_by_name) : NULL;
  $authmap_uid = $this->externalAuth
    ->getUid($this->authName, 'ldap_user');
  if (!$this->drupalUser && $authmap_uid) {

    // Drupal username differs but we have a UID in the authmap table for it.
    $this->drupalUser = $this->entityTypeManager
      ->getStorage('user')
      ->load($authmap_uid);
  }
  if ($this->drupalUser && $authmap_uid) {
    $this->drupalUserAuthMapped = TRUE;
  }
}