private function DrupalUserProcessor::syncToDrupalAccount 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::syncToDrupalAccount()
For a Drupal account, query LDAP, get all user fields and set them.
Return value
bool Attempts to sync, reports failure if unsuccessful.
3 calls to DrupalUserProcessor::syncToDrupalAccount()
- DrupalUserProcessor::drupalUserLogsIn in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Handle Drupal user login.
- DrupalUserProcessor::drupalUserUpdate in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Callback for hook_ENTITY_TYPE_update().
- DrupalUserProcessor::updateExistingAccountByPersistentUid in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Update Drupal user from PUID.
File
- ldap_user/
src/ Processor/ DrupalUserProcessor.php, line 647
Class
- DrupalUserProcessor
- Handles processing of a user from LDAP to Drupal.
Namespace
Drupal\ldap_user\ProcessorCode
private function syncToDrupalAccount() : bool {
if (!$this->account instanceof UserInterface) {
$this->logger
->notice('Invalid selection passed to syncToDrupalAccount.');
return FALSE;
}
if (property_exists($this->account, 'ldap_synced')) {
// We skip syncing if we already did add the fields on the user.
return FALSE;
}
if (!$this->ldapEntry && $this->config
->get('drupalAcctProvisionServer')) {
$this->ldapUserManager
->setServerById($this->config
->get('drupalAcctProvisionServer'));
$this->ldapEntry = $this->ldapUserManager
->getUserDataByAccount($this->account);
}
if (!$this->ldapEntry) {
return FALSE;
}
if ($this->config
->get('drupalAcctProvisionServer')) {
$this->server = $this->entityTypeManager
->getStorage('ldap_server')
->load($this->config
->get('drupalAcctProvisionServer'));
$this
->applyAttributesToAccount();
$this->account->ldap_synced = TRUE;
}
return TRUE;
}