private function OrphanProcessor::ldapQueryEligibleUser in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_user/src/Processor/OrphanProcessor.php \Drupal\ldap_user\Processor\OrphanProcessor::ldapQueryEligibleUser()
Check eligible user against directory.
Parameters
int $uid: User ID.
string $serverId: Server ID.
string $persistentUidProperty: PUID Property.
string $persistentUid: PUID.
Return value
array Eligible user data.
1 call to OrphanProcessor::ldapQueryEligibleUser()
- OrphanProcessor::batchQueryUsers in ldap_user/
src/ Processor/ OrphanProcessor.php - Batch query for users.
File
- ldap_user/
src/ Processor/ OrphanProcessor.php, line 257
Class
- OrphanProcessor
- Locates potential orphan user accounts.
Namespace
Drupal\ldap_user\ProcessorCode
private function ldapQueryEligibleUser($uid, $serverId, $persistentUidProperty, $persistentUid) {
$user['uid'] = $uid;
$user['exists'] = FALSE;
// Query LDAP and update the prepared users with the actual state.
if (!isset($this->enabledServers[$serverId])) {
if (!isset($this->missingServerSemaphore[$serverId])) {
$this->logger
->error('Server %id not enabled, but needed to remove orphaned LDAP users', [
'%id' => $serverId,
]);
$this->missingServerSemaphore[$serverId] = TRUE;
}
}
else {
if ($this->enabledServers[$serverId]
->get('unique_persistent_attr_binary')) {
$filter = "({$persistentUidProperty}=" . $this
->binaryFilter($persistentUid) . ")";
}
else {
$filter = "({$persistentUidProperty}={$persistentUid})";
}
$ldapEntries = $this->enabledServers[$serverId]
->searchAllBaseDns($filter, [
$persistentUidProperty,
]);
if ($ldapEntries === FALSE) {
$this->logger
->error('LDAP server %id had error while querying to deal with orphaned LDAP user entries. Please check that the LDAP server is configured correctly', [
'%id' => $serverId,
]);
return [];
}
else {
unset($ldapEntries['count']);
if (!empty($ldapEntries)) {
$user['exists'] = TRUE;
}
}
}
return $user;
}