Code

Removed ldap_explode_dn and replaced it with self made app.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Sep 2006 11:23:59 +0000 (11:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Sep 2006 11:23:59 +0000 (11:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4800 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_ldap.inc
include/functions.inc
include/functions_FAI.inc
plugins/admin/systems/class_systemManagement.inc

index 02cb696f9ad6a50966b94f2d22478350952a89ed..e5809d72099e075eb69c1fdbd23d80e1c098f6b7 100644 (file)
@@ -645,7 +645,7 @@ class LDAP{
     }
 
     $real_path= substr($target, 0, strlen($target) - strlen($this->basedn) -1 );
-    $l= array_reverse(ldap_explode_dn($real_path,0));
+    $l= array_reverse(gosa_ldap_explode_dn($real_path));
     unset($l['count']);
     $cdn= $this->basedn;
     $tag= "";
@@ -1098,7 +1098,7 @@ class LDAP{
     if(isset($data['dn'])) {
 
       /* Fix dn */
-      $tmp = ldap_explode_dn($data['dn'],0);
+      $tmp = gosa_ldap_explode_dn($data['dn']);
       unset($tmp['count']);
       $newdn ="";
       foreach($tmp as $tm){
index 06b898405718ebaf18ea2124aa3094ede31a112b..e3254ed350608a960fe680f3845b36bf2da280fd 100644 (file)
@@ -2176,6 +2176,59 @@ function obj_is_writable($dn, $object, $attribute)
 }
 
 
+function gosa_ldap_explode_dn($dn,$config = NULL,$verify_in_ldap=false)
+{
+  /* Initialize variables */
+  $ret  = array("count" => 0);  // Set count to 0
+  $next = true;                 // if false, then skip next loops and return
+  $cnt  = 0;                    // Current number of loops
+  $max  = 100;                  // Just for security, prevent looops
+  $ldap = NULL;                 // To check if created result a valid
+  $keep = "";                   // save last failed parse string
+
+  /* Check each parsed dn in ldap ? */
+  if($config!=NULL && $verify_in_ldap){
+    $ldap = $config->get_ldap_link();
+  }
+
+  $Diff = ldap_explode_dn($dn,0);
+
+  /* Lets start */
+  while(preg_match("/,/",$dn) && $next &&  $cnt < $max){
+
+    $cnt ++;
+    if(!preg_match("/,/",$dn)){
+      $next = false;
+    }
+    $object = preg_replace("/[,].*$/","",$dn);
+    $dn     = preg_replace("/^[^,]+,/","",$dn);
+
+    /* Check if current dn is valid */
+    if($ldap!=NULL){
+      $ldap->cd($dn);
+      $ldap->cat($dn,array("dn"));
+      if($ldap->count()){
+        $ret[]  = $keep.$object;
+        $keep   = "";
+      }else{
+        $keep  .= $object.",";
+      }
+    }else{
+      $ret[]  = $keep.$object;
+      $keep   = "";
+    }
+  }
+
+  /* Append the rest */
+  $ret[] = $keep.$dn;
+  $ret['count'] = count($ret) - 1;
+
+  $diff = array_diff($ret,$Diff);
+  if($diff){
+    print_a(array("Diff" => $diff,"OLD" => $Diff,"NEW"=> $ret,"DEBUG"=> debug_backtrace()));
+  }
+  return($ret);
+}
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 2c9297cad61318ec18086630e0982d10710fb70a..781f66c93386b5cc222b33aa0502d6f335e9bad7 100644 (file)
@@ -575,9 +575,8 @@ function get_previous_releases_of_this_release($dn,$flat)
   $ret = array();
 
   /* Explode dns into pieces, to be able to build parent dns */
-#  $dns_to_check = ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$dn),0);
-  $dns_to_check = ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$dn),0);
-  echo "<font color='red'>Replace ldap_explode_dn it is evil, it changes characters within result... </font><br>";
+#  $dns_to_check = gosa_ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$dn),0);
+  $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$dn));
 
   if(!is_array($dns_to_check)){
     return;  
@@ -682,9 +681,8 @@ function get_release_dn($Current_DN)
   $ldap->cd($config->current['BASE']);
 
   /* Split dn into pices */ 
-#  $dns_to_check = ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$Current_DN),0);
-  $dns_to_check = ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$Current_DN),0);
-  echo "<font color='red'>Replace ldap_explode_dn it is evil, it changes characters within result... </font><br>";
+#  $dns_to_check = gosa_ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$Current_DN),0);
+  $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$Current_DN));
 
   if(!is_array($dns_to_check)){
     return;  
index 6c9483be6cf10ffac9db2da256efe8b7c8708bc7..0cdbb80b8be8f2d81f63561cd0234c001202c9bd 100644 (file)
@@ -153,7 +153,7 @@ class systems extends plugin
         $tabclass = $tabs[$sw]["TABCLASS"];
         $acl_cat  = $tabs[$sw]["ACL"];
         $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
-        $this->systab->set_acl_base($this->base);
+        $this->systab->set_acl_base($this->DivListSystem->selectedBase);
         $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
         $this->systab->base = $this->DivListSystem->selectedBase;
       }