From 2fb21a49165f93a3a57e2aced57bf496baaeb488 Mon Sep 17 00:00:00 2001 From: psc Date: Mon, 29 Jun 2009 09:03:35 +0000 Subject: [PATCH] Rewrite get_parent_object(..) so that it uses gosa_explode_dn instead of preg_replace, because it should avoid potential problems with ',' in DNs git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13813 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../gosa-plugins/fai/admin/fai/class_FAI.inc | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc index e00cca4e6..2a1dfe0da 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc @@ -1329,23 +1329,31 @@ class FAI { global $config; $Current_DN = $dn; + $i = 0; $tmp_dn = $Current_DN; - $parent_dn = $tmp_dn; + $parent_dn = array(); /* special case partitions, as they don't start with cn= in their DN (schema bug?) */ $tmp_dn = preg_replace('/^FAIpartitionNr=/', 'cn=', $tmp_dn); - while (preg_match('/^cn=/', $tmp_dn)){ - $parent_dn = $tmp_dn; - $tmp_dn = preg_replace('/^cn=[^,.]*,/', '', $parent_dn); + $tmp_dn = gosa_ldap_explode_dn($tmp_dn); + while(preg_match('/^cn=/', $tmp_dn[$i])) { + $i++; } + /* DN part does not start with cn= anymore, remove one from the counter to get the + last CN element */ + $i--; + + for ($i;$i<$tmp_dn['count'];$i++) { + $parent_dn[] = trim($tmp_dn[$i]); + } + $parent_dn = join($parent_dn, ','); + if ($parent_dn != $Current_DN){ $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); $ldap->cat($parent_dn); - - /* Check objectClasses and name to check if this is a release department */ if($ldap->count()){ return $parent_dn; } -- 2.30.2