From debae573752557eb5a0d09189ff40eca92c3735b Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 27 Sep 2006 11:23:59 +0000 Subject: [PATCH] Removed ldap_explode_dn and replaced it with self made app. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4800 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ldap.inc | 4 +- include/functions.inc | 53 +++++++++++++++++++ include/functions_FAI.inc | 10 ++-- .../admin/systems/class_systemManagement.inc | 2 +- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 02cb696f9..e5809d720 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -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){ diff --git a/include/functions.inc b/include/functions.inc index 06b898405..e3254ed35 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -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: ?> diff --git a/include/functions_FAI.inc b/include/functions_FAI.inc index 2c9297cad..781f66c93 100644 --- a/include/functions_FAI.inc +++ b/include/functions_FAI.inc @@ -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 "Replace ldap_explode_dn it is evil, it changes characters within result...
"; +# $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 "Replace ldap_explode_dn it is evil, it changes characters within result...
"; +# $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; diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index 6c9483be6..0cdbb80b8 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -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; } -- 2.30.2