public function LdapBaseManager::sanitizeUserDataResponse in Lightweight Directory Access Protocol (LDAP) 8.4
Sanitize user data response.
Parameters
\Symfony\Component\Ldap\Entry $entry: LDAP entry.
string $drupal_username: Drupal username.
Return value
\Symfony\Component\Ldap\Entry|null LDAP Entry.
2 calls to LdapBaseManager::sanitizeUserDataResponse()
- LdapBaseManager::matchUsernameToExistingLdapEntry in ldap_servers/
src/ LdapBaseManager.php - Match username to existing LDAP entry.
- LdapUserManager::getUserDataByIdentifier in ldap_servers/
src/ LdapUserManager.php - Fetch user data from server by Identifier.
File
- ldap_servers/
src/ LdapBaseManager.php, line 411
Class
- LdapBaseManager
- LDAP Base Manager.
Namespace
Drupal\ldap_serversCode
public function sanitizeUserDataResponse(Entry $entry, string $drupal_username) : ?Entry {
if ($this->server
->get('bind_method') === 'anon_user') {
return $entry;
}
// Filter out results with spaces added before or after, which are
// considered OK by LDAP but are no good for us. Some setups have multiple
// $nameAttribute per entry, so we loop through all possible options.
$attribute_values = $entry
->getAttribute($this->server
->getAuthenticationNameAttribute(), FALSE);
if ($attribute_values) {
foreach ($attribute_values as $attribute_value) {
if (mb_strtolower(trim($attribute_value)) === mb_strtolower($drupal_username)) {
return $entry;
}
}
}
return NULL;
}