summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e996d2b)
raw | patch | inline | side by side (parent: e996d2b)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Feb 2008 08:11:21 +0000 (08:11 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Feb 2008 08:11:21 +0000 (08:11 +0000) |
-get_sub_list improvements.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9044 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9044 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/functions.inc | patch | blob | history |
index 07990f8e24a9451bac8c30ebc452ebd6dfef3e4f..1da4e832c9b95fead61c302f443836260335dc7a 100644 (file)
@param $attributes Array The attributes we search for.
@param $flags Long A set of Flags
*/
-function get_sub_list($filter, $category,$sub_bases, $base= "", $attributes= array(), $flags= GL_SUBSEARCH)
+function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= array(), $flags= GL_SUBSEARCH)
{
global $config, $ui;
@@ -770,12 +770,13 @@ function get_sub_list($filter, $category,$sub_bases, $base= "", $attributes= arr
}
/* Ensure we have an array as department list */
- if(is_string($sub_bases)){
- $sub_bases = array($sub_bases);
+ if(is_string($sub_deps)){
+ $sub_deps = array($sub_deps);
}
/* Remove , ("ou=1,ou=2.." => "ou=1") */
- foreach($sub_bases as $key => $sub_base){
+ $sub_bases = array();
+ foreach($sub_deps as $key => $sub_base){
$sub_bases[$key] = preg_replace("/,.*$/","",$sub_base);
}
@@ -797,16 +798,28 @@ function get_sub_list($filter, $category,$sub_bases, $base= "", $attributes= arr
/* Get all deparments matching the given sub_bases */
$departments = array();
-
$base_filter= "";
foreach($sub_bases as $sub_base){
$base_filter .= "(".$sub_base.")";
}
$base_filter = "(&(objectClass=organizationalUnit)(|".$base_filter."))";
-
$ldap->search($base_filter,array("dn"));
while($attrs = $ldap->fetch()){
- $departments[$attrs['dn']] = $attrs['dn'];
+ foreach($sub_deps as $sub_dep){
+
+ /* Only add those departments that match the reuested list of departments.
+ *
+ * e.g. sub_deps = array("ou=servers,ou=systems,");
+ *
+ * In this case we have search for "ou=servers" and we may have also fetched
+ * departments like this "ou=servers,ou=blafasel,..."
+ * Here we filter out those blafasel departments.
+ */
+ if(preg_match("/".normalizePreg($sub_dep)."/",$attrs['dn'])){
+ $departments[$attrs['dn']] = $attrs['dn'];
+ break;
+ }
+ }
}
$result= array();