protected static function _correctDNSplitting($dn = array(), $separator = ',')
{
foreach ($dn as $key => $dn_value) {
// Refresh value (foreach caches!)
$dn_value = $dn[$key];
// If $dn_value is not in attr=value format, we had an unescaped
// separator character inside the attr name or the value. We assume
// that it was the attribute value.
// TODO: To solve this, we might ask the schema. The
// Horde_Ldap_Util class must remain independent from the
// other classes or connections though.
if (!preg_match('/.+(?<!\\\\)=.+/', $dn_value)) {
unset($dn[$key]);
if (array_key_exists($key - 1, $dn)) {
// Append to previous attribute value.
$dn[$key - 1] = $dn[$key - 1] . $separator . $dn_value;
} elseif (array_key_exists($key + 1, $dn)) {
// First element: prepend to next attribute name.
$dn[$key + 1] = $dn_value . $separator . $dn[$key + 1];
} else {
$dn[$key] = $dn_value;
}
}
}
return array_values($dn);
}