From ccbf1e4e1c517ddb210bdedb46b70761e92ef23e Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 4 Nov 2008 16:10:43 +0000 Subject: [PATCH] Reverted Speed improvements which led into problems while copying deparments with special chars git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12905 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 36 ++++++++++++++++-------------- gosa-core/include/class_plugin.inc | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index a0c46a7cc..1c8b758f2 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -81,18 +81,20 @@ class LDAP{ /* Function to replace all problematic characters inside a DN by \001XX, where \001 is decoded to chr(1) [ctrl+a]. It is not impossible, but very unlikely that this character is inside a DN. - + Currently used codes: - , => CO - \2C => CO - ( => OB - ) => CB - / => SL */ + , => CO + \2C => CO + ( => OB + ) => CB + / => SL */ static function convert($dn) { - if (SPECIALS_OVERRIDE === TRUE){ - return preg_replace('/,\s+/', ',', str_replace(array('\\\\,', '\\\\2C', '\(/', '/\)', '\/'), - array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"), $dn)); + if (SPECIALS_OVERRIDE == TRUE){ + $tmp= preg_replace(array("/\\\\,/", "/\\\\2C/", "/\(/", "/\)/", "/\//"), + array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"), + $dn); + return (preg_replace('/,\s+/', ',', $tmp)); } else { return ($dn); } @@ -105,20 +107,20 @@ class LDAP{ servers seem to take it the correct way. */ static function fix($dn) { - if (SPECIALS_OVERRIDE === TRUE){ - return (str_replace(array('\001CO', '\001OB', '\001CB', '\001SL'), - array('\,', '(', ')', '/'), $dn)); + if (SPECIALS_OVERRIDE == TRUE){ + return (preg_replace(array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/"), + array("\,", "(", ")", "/"), + $dn)); } else { return ($dn); } } - /* Function to fix problematic characters in DN's that are used for search requests. I.e. member=.... */ static function prepare4filter($dn) { - return normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn))); + return normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn))); } @@ -480,12 +482,12 @@ class LDAP{ parent => ou=department,dc=... dest_rdn => cn=herbert */ - $parent = @LDAP::fix(preg_replace("/^[^,]+,/","", @LDAP::convert($dest))); - $dest_rdn = @LDAP::fix(preg_replace("/,.*$/","",@LDAP::convert($dest))); + $parent = preg_replace("/^[^,]+,/","", $dest); + $dest_rdn = preg_replace("/,.*$/","",$dest); if($this->hascon){ if ($this->reconnect) $this->connect(); - $r= ldap_rename($this->cid,$source,$dest_rdn,$parent,TRUE); + $r= ldap_rename($this->cid,@LDAP::fix($source), @LDAP::fix($dest_rdn),@LDAP::fix($parent),TRUE); $this->error = ldap_error($this->cid); /* Check if destination dn exists, if not the diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 95abb82d8..dee53fbb0 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -912,7 +912,7 @@ class plugin /* Try to move the source entry to the destination position */ $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",@LDAP::convert($dst_dn))); + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$dst_dn)); if (!$ldap->rename_dn($src_dn,$dst_dn)){ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $src_dn, "", get_class())); -- 2.30.2