public function testSlapdExplodeDn()
 {
     $actual = SHLdap::explodeDn('uid=oracle,  ou=Matrix,  ou = People,  dc=shmanic, dc=net', 0);
     $this->assertEquals(array('count' => 5, 'uid=oracle', 'ou=Matrix', 'ou=People', 'dc=shmanic', 'dc=net'), $actual);
 }
Beispiel #2
0
 /**
  * Compare the DN in the parameter against the groups in
  * the ldap groups. This is used to compare if one of the
  * group mapping list dn entries matches any of the ldap user
  * groups and if so returns true.
  *
  * @param   self  $parameter    Group mapping list parameters.
  * @param   self  &$ldapGroups  Ldap user groups.
  *
  * @return  Boolean  True on parameter entry is in the ldap user group.
  *
  * @since   1.0
  */
 public static function compareGroup(self $parameter, self &$ldapGroups)
 {
     $matches = array();
     if ($parameter->dn === false || $ldapGroups->dn === false) {
         // Distinguished Name has invalid syntax
         return false;
     }
     foreach ($ldapGroups->groups as $ldapGroup) {
         /*
          * If there is currently no RDNs (i.e. non validated DN)
          * then we will use a simple string comparison.
          */
         if (count($parameter->rdn)) {
             $explode = SHLdap::explodeDn($ldapGroup, 0);
             if (is_array($explode) && count($explode)) {
                 // We need to convert to lower because escape characters return with uppercase hex ascii codes
                 $explode = array_map('strToLower', SHLdap::explodeDn($ldapGroup, 0));
                 if (self::compareValidatedDN($parameter->rdn, $explode)) {
                     return true;
                 }
             }
         } else {
             // Simple string comparison instead of the validated DN method
             if (strToLower(trim($ldapGroup)) == strToLower(trim($parameter->dn))) {
                 return true;
             }
         }
     }
 }