You are here

public function LdapGroupManager::getAllRdnValuesFromDn in Lightweight Directory Access Protocol (LDAP) 8.4

Returns all RDN values from DN.

Given a DN (such as cn=jdoe,ou=people) and an rdn (such as cn), determine that RDN value (such as jdoe).

Parameters

string $dn: Input DN.

string $rdn: RDN Value to find.

Return value

array All values of RDN.

1 call to LdapGroupManager::getAllRdnValuesFromDn()
LdapGroupManager::groupUserMembershipsFromDn in ldap_servers/src/LdapGroupManager.php
Get "groups" from derived from DN.

File

ldap_servers/src/LdapGroupManager.php, line 754

Class

LdapGroupManager
LDAP Group Manager.

Namespace

Drupal\ldap_servers

Code

public function getAllRdnValuesFromDn(string $dn, string $rdn) : array {

  // Escapes attribute values, need to be unescaped later.
  $pairs = self::splitDnWithAttributes($dn);
  array_shift($pairs);
  $rdn = mb_strtolower($rdn);
  $rdn_values = [];
  foreach ($pairs as $p) {
    $pair = explode('=', $p);
    if ($pair !== FALSE && mb_strtolower(trim($pair[0])) === $rdn) {
      $rdn_values[] = ConversionHelper::unescapeDnValue(trim($pair[1]));
      break;
    }
  }
  return $rdn_values;
}