private function LoginValidator::updateAuthNameFromPuid in Lightweight Directory Access Protocol (LDAP) 8.3
Update the authName if it's no longer valid.
Drupal account does not exist for authName used to logon, but puid exists in another Drupal account; this means username has changed and needs to be saved in Drupal account.
2 calls to LoginValidator::updateAuthNameFromPuid()
- 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 746
Class
- LoginValidator
- Handles the actual testing of credentials and authentication of users.
Namespace
Drupal\ldap_authentication\ControllerCode
private function updateAuthNameFromPuid() {
$puid = $this->serverDrupalUser
->userPuidFromLdapEntry($this->ldapUser['attr']);
if ($puid) {
$this->drupalUser = $this->serverDrupalUser
->userAccountFromPuid($puid);
/** @var \Drupal\user\Entity\User $userMatchingPuid */
if ($this->drupalUser) {
$oldName = $this->drupalUser
->getAccountName();
$this->drupalUser
->setUsername($this->drupalUserName);
$this->drupalUser
->save();
ExternalAuthenticationHelper::setUserIdentifier($this->drupalUser, $this->authName);
$this->drupalUserAuthMapped = TRUE;
drupal_set_message($this
->t('Your existing account %username has been updated to %new_username.', [
'%username' => $oldName,
'%new_username' => $this->drupalUserName,
]), 'status');
}
}
}