public static function LdapTransformationTraits::splitDnWithAttributes in Lightweight Directory Access Protocol (LDAP) 8.4
Wrapper for ldap_explode_dn().
Try to avoid working with DN directly and instead use Entry objects.
Parameters
string $dn: DN to explode.
Return value
array Exploded DN.
3 calls to LdapTransformationTraits::splitDnWithAttributes()
- LDAPAuthorizationProvider::sanitizeProposals in ldap_authorization/
src/ Plugin/ authorization/ Provider/ LDAPAuthorizationProvider.php - Sanitize proposals.
- LdapGroupManager::getAllRdnValuesFromDn in ldap_servers/
src/ LdapGroupManager.php - Returns all RDN values from DN.
- TokenProcessor::processDnParts in ldap_servers/
src/ Processor/ TokenProcessor.php - Deconstruct DN parts.
File
- ldap_servers/
src/ LdapTransformationTraits.php, line 167
Class
- LdapTransformationTraits
- Helper functions to work around hard dependencies on the LDAP extension.
Namespace
Drupal\ldap_serversCode
public static function splitDnWithAttributes(string $dn) : array {
if (\function_exists('ldap_explode_dn')) {
return ldap_explode_dn($dn, 0);
}
$rdn = explode(',', $dn);
$rdn = array_map(static function ($attribute) {
$attribute = trim($attribute);
// This is a workaround for OpenLDAP escaping Unicode values.
[
$key,
$value,
] = explode('=', $attribute);
$value = str_replace('%', '\\', urlencode($value));
return implode('=', [
$key,
$value,
]);
}, $rdn);
return [
'count' => count($rdn),
] + $rdn;
}