You are here

private function LoginValidator::matchExistingUserWithLdap in Lightweight Directory Access Protocol (LDAP) 8.3

Match existing user with LDAP.

Return value

bool User matched.

2 calls to LoginValidator::matchExistingUserWithLdap()
LoginValidator::processLogin in ldap_authentication/src/Controller/LoginValidator.php
Perform the actual logging in.
LoginValidator::processSsoLogin in ldap_authentication/src/Controller/LoginValidator.php
Processes an SSO login.

File

ldap_authentication/src/Controller/LoginValidator.php, line 866

Class

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

Namespace

Drupal\ldap_authentication\Controller

Code

private function matchExistingUserWithLdap() {
  if ($this->configFactory
    ->get('ldap_user.settings')
    ->get('userConflictResolve') == self::USER_CONFLICT_LOG) {
    if ($account_with_same_email = user_load_by_mail($this->ldapUser['mail'])) {

      /** @var \Drupal\user\UserInterface $account_with_same_email */
      $this->logger
        ->error('LDAP user with DN %dn has a naming conflict with a local Drupal user %conflict_name', [
        '%dn' => $this->ldapUser['dn'],
        '%conflict_name' => $account_with_same_email
          ->getAccountName(),
      ]);
    }
    drupal_set_message($this
      ->t('Another user already exists in the system with the same login name. You should contact the system administrator in order to solve this conflict.'), 'error');
    return FALSE;
  }
  else {
    ExternalAuthenticationHelper::setUserIdentifier($this->drupalUser, $this->authName);
    $this->drupalUserAuthMapped = TRUE;
    $this->detailLog
      ->log('Set authmap for LDAP user %username', [
      '%username' => $this->authName,
    ], 'ldap_authentication');
  }
  return TRUE;
}