Adldap\Utilities::explodeDn PHP Method

explodeDn() public static method

This will also decode hex characters into their true UTF-8 representation embedded inside the DN as well.
public static explodeDn ( string $dn, boolean $removeAttributePrefixes = true ) : array | false
$dn string
$removeAttributePrefixes boolean
return array | false
    public static function explodeDn($dn, $removeAttributePrefixes = true)
    {
        $dn = ldap_explode_dn($dn, $removeAttributePrefixes ? 1 : 0);
        if (is_array($dn) && array_key_exists('count', $dn)) {
            foreach ($dn as $rdn => $value) {
                $dn[$rdn] = self::unescape($value);
            }
        }
        return $dn;
    }

Usage Example

Example #1
0
 /**
  * Returns the group's member names only.
  *
  * @return array
  */
 public function getMemberNames()
 {
     $members = [];
     $dns = $this->getAttribute($this->schema->member()) ?: [];
     foreach ($dns as $dn) {
         $exploded = Utilities::explodeDn($dn);
         if (array_key_exists(0, $exploded)) {
             $members[] = $exploded[0];
         }
     }
     return $members;
 }
All Usage Examples Of Adldap\Utilities::explodeDn