protected function _filter_ldap_result($data, $performConversion) { $result = array(); $cleanResult = array(); unset($data['count']); foreach ($data as $property => $value) { // There might be numeric keys, indicating the name of the attribute - just skip them... if (is_numeric($property)) { continue; } if (is_array($value)) { unset($value['count']); } // Some ldap servers ( i.e. AD ) may split too large attributes into smaller // attributes with a special notation in the attribute's name ( i.e. "member;0-4999" ). // Let's join those together. // Search for ';' in $property, returning string BEFORE needle $realProperty = strstr($property, ';', true); if ($realProperty) { if (array_key_exists($realProperty, $cleanResult)) { // If that attribute already exists, join the two together $cleanResult[$realProperty] = array_merge($cleanResult[$realProperty], $value); } else { $cleanResult[$realProperty] = $value; } } else { $cleanResult[$property] = $value; } } // Create the Attribute objects foreach ($cleanResult as $attribute => $value) { $result[$attribute] = Attribute::make($attribute, $value, $this, $performConversion); } // Return the clean data return $result; }
/** * Convert the raw ldap data into binary string instead of keeping it as hexadecimal value * * @return array The data in binary format */ public function ldap_data() { $data = parent::ldap_data(); return count($data) > 0 ? hex2bin(str_ireplace('\\', '', $data[0])) : array(); // Empty attributes are represented as empty arrays }