public function DrupalUserProcessor::ldapExcludeDrupalAccount in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 ldap_user/src/Processor/DrupalUserProcessor.php \Drupal\ldap_user\Processor\DrupalUserProcessor::ldapExcludeDrupalAccount()
Set flag to exclude user from LDAP association.
Parameters
string $drupalUsername: The account username.
Return value
bool TRUE on success, FALSE on error or failure because of invalid user.
File
- ldap_user/
src/ Processor/ DrupalUserProcessor.php, line 385
Class
- DrupalUserProcessor
- Handles processing of a user from LDAP to Drupal.
Namespace
Drupal\ldap_user\ProcessorCode
public function ldapExcludeDrupalAccount(string $drupalUsername) : bool {
/** @var \Drupal\user\Entity\User $account */
$accounts = $this->entityTypeManager
->getStorage('user')
->loadByProperties([
'name' => $drupalUsername,
]);
if (!$accounts) {
$this->logger
->error('Failed to exclude user from LDAP association because Drupal account %username was not found', [
'%username' => $drupalUsername,
]);
return FALSE;
}
$account = reset($accounts);
$account
->set('ldap_user_ldap_exclude', 1);
return (bool) $account
->save();
}