protected function utf8($attributes, $function)
{
if (!is_array($attributes) || array_key_exists(0, $attributes)) {
throw new Horde_Ldap_Exception('Parameter $attributes is expected to be an associative array');
}
if (!$this->_schema) {
$this->_schema = $this->schema();
}
if (!$this->_link || !function_exists($function)) {
return $attributes;
}
if (is_array($attributes) && count($attributes) > 0) {
foreach ($attributes as $k => $v) {
if (!isset($this->_schemaAttrs[$k])) {
try {
$attr = $this->_schema->get('attribute', $k);
} catch (Exception $e) {
continue;
}
if (false !== strpos($attr['syntax'], '1.3.6.1.4.1.1466.115.121.1.15')) {
$encode = true;
} else {
$encode = false;
}
$this->_schemaAttrs[$k] = $encode;
} else {
$encode = $this->_schemaAttrs[$k];
}
if ($encode) {
if (is_array($v)) {
foreach ($v as $ak => $av) {
$v[$ak] = call_user_func($function, $av);
}
} else {
$v = call_user_func($function, $v);
}
}
$attributes[$k] = $v;
}
}
return $attributes;
}