public function ServerFactory::getUserDataByAccount in Lightweight Directory Access Protocol (LDAP) 8.3
Fetch user data from account.
Uses the regular provisioning server.
Parameters
\Drupal\user\UserInterface $account: Drupal user account.
array $ldap_context: LDAP context.
Return value
array|bool Returns data or FALSE.
File
- ldap_servers/
src/ ServerFactory.php, line 176
Class
- ServerFactory
- Helper class to working with the Server classes.
Namespace
Drupal\ldap_serversCode
public function getUserDataByAccount(UserInterface $account, array $ldap_context = NULL) {
$provisioningServer = $this
->config('ldap_user.settings')
->get('drupalAcctProvisionServer');
$id = NULL;
if (!$account) {
return FALSE;
}
// TODO: While this functionality is now consistent with 7.x, it hides
// a corner case: server which are no longer available can still be set in
// the user as a preference and those users will not be able to sync.
// This needs to get cleaned up or fallback differently.
if (property_exists($account, 'ldap_user_puid_sid') && !empty($account
->get('ldap_user_puid_sid')->value)) {
$id = $account
->get('ldap_user_puid_sid')->value;
}
elseif ($provisioningServer) {
$id = $provisioningServer;
}
else {
$servers = $this
->getEnabledServers();
if (count($servers) == 1) {
$ids = array_keys($servers);
$id = $ids[0];
}
else {
$this->logger
->error('Multiple servers enabled, one has to be set up for user provision.');
return FALSE;
}
}
return $this
->getUserDataFromServerByAccount($account, $id, $ldap_context);
}