Code

Reverted Speed improvements which led into problems while copying deparments with...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 Nov 2008 16:10:43 +0000 (16:10 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 Nov 2008 16:10:43 +0000 (16:10 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12905 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc
gosa-core/include/class_plugin.inc

index a0c46a7cc6de9d16ee098c506bd0b41569e23df7..1c8b758f287860581b6285bbf18ba288b20f3b0d 100644 (file)
@@ -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 
index 95abb82d8865340d6565f5fd9f85ea6fbb67e250..dee53fbb0e430cf55c139e40fba865d2404c849c 100644 (file)
@@ -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()));