protected function LoginValidatorBase::matchExistingUserWithLdap in Lightweight Directory Access Protocol (LDAP) 8.4
Match existing user with LDAP.
Return value
bool User matched.
2 calls to LoginValidatorBase::matchExistingUserWithLdap()
- LoginValidatorLoginForm::processLogin in ldap_authentication/
src/ Controller/ LoginValidatorLoginForm.php - Perform the actual logging in.
- LoginValidatorSso::processLogin in ldap_authentication/
src/ Controller/ LoginValidatorSso.php - Perform the actual logging in.
File
- ldap_authentication/
src/ Controller/ LoginValidatorBase.php, line 740
Class
- LoginValidatorBase
- Handles the actual testing of credentials and authentication of users.
Namespace
Drupal\ldap_authentication\ControllerCode
protected function matchExistingUserWithLdap() : bool {
if ($this->configFactory
->get('ldap_user.settings')
->get('userConflictResolve') === self::USER_CONFLICT_LOG) {
$users = $this->entityTypeManager
->getStorage('user')
->loadByProperties([
'mail' => $this->serverDrupalUser
->deriveEmailFromLdapResponse($this->ldapEntry),
]);
if (count($users) > 0) {
/** @var \Drupal\user\UserInterface $account_with_same_email */
$account_with_same_email = reset($users);
$this->logger
->error('LDAP user with DN %dn has a naming conflict with a local Drupal user %conflict_name', [
'%dn' => $this->ldapEntry
->getDn(),
'%conflict_name' => $account_with_same_email
->getAccountName(),
]);
}
$this->messenger
->addError($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.'));
return FALSE;
}
$this->externalAuth
->save($this->drupalUser, 'ldap_user', $this->authName);
$this->drupalUserAuthMapped = TRUE;
$this->detailLog
->log('Set authmap for LDAP user %username', [
'%username' => $this->authName,
], 'ldap_authentication');
return TRUE;
}