public function DrupalUserProcessor::ldapExcludeDrupalAccount in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 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 198
Class
- DrupalUserProcessor
- Handles processing of a user from LDAP to Drupal.
Namespace
Drupal\ldap_user\ProcessorCode
public function ldapExcludeDrupalAccount($drupalUsername) {
$account = User::load($drupalUsername);
if (!$account) {
\Drupal::logger('ldap_user')
->error('Failed to exclude user from LDAP association because Drupal account %username was not found', [
'%username' => $drupalUsername,
]);
return FALSE;
}
$account
->set('ldap_user_ldap_exclude', 1);
$account
->save();
return (bool) $account;
}