X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_filterLDAP.inc;h=5a6701d65540462693a5b681e7b475167d8e2a60;hb=3a308e40188042fb56365af23190514a85621963;hp=f0f8ca740881a3574c67d49140cbc96ee3d4e650;hpb=e9feb085c421af65246962bf60757aba9ce8e944;p=gosa.git diff --git a/gosa-core/include/class_filterLDAP.inc b/gosa-core/include/class_filterLDAP.inc index f0f8ca740..5a6701d65 100644 --- a/gosa-core/include/class_filterLDAP.inc +++ b/gosa-core/include/class_filterLDAP.inc @@ -14,8 +14,8 @@ class filterLDAP { static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH) { - global $ui; - global $config; + $ui= session::global_get('ui'); + $config= session::global_get('config'); // Move to arrays for category and objectStorage if (!is_array($category)) { @@ -28,28 +28,29 @@ class filterLDAP { // Initialize search bases $bases= array(); - // Get list of sub bases to search on and fill dn components to search for - $components= array(); - foreach ($objectStorage as $oc) { - $oc= preg_replace('/,$/', '', $oc); - $tmp= split(',', $oc); - if (count($tmp) == 1) { - preg_match('/([^=]+)=(.*)$/', $oc, $m); - $components[]= $m[1].":dn:=".$m[2]; - if ($flags & GL_SUBSEARCH) { - $bases[$base][]= $m[1].":dn:=".$m[2]; - } else { - $bases["$oc,$base"][]= $m[1].":dn:=".$m[2]; - } - } else { - // No, there's no \, in pre defined RDN values - preg_match('/^([^,]+),(.*)$/', $oc, $matches); - preg_match('/([^=]+)=(.*)$/', $matches[1], $m); - $components[]= $m[1].":dn:=".$m[2]; - if ($flags & GL_SUBSEARCH) { - $bases[$base][]= $m[1].":dn:=".$m[2]; + // Get list of sub bases to search on + if (count($objectStorage) == 0) { + $bases[$base]= ""; + } else { + foreach ($objectStorage as $oc) { + $oc= preg_replace('/,$/', '', $oc); + $tmp= split(',', $oc); + if (count($tmp) == 1) { + preg_match('/([^=]+)=(.*)$/', $oc, $m); + if ($flags & GL_SUBSEARCH) { + $bases[$base][]= $m[1].":dn:=".$m[2]; + } else { + $bases["$oc,$base"][]= $m[1].":dn:=".$m[2]; + } } else { - $bases[$matches[2].",$base"][]= $m[1].":dn:=".$m[2]; + // No, there's no \, in pre defined RDN values + preg_match('/^([^,]+),(.*)$/', $oc, $matches); + preg_match('/([^=]+)=(.*)$/', $matches[1], $m); + if ($flags & GL_SUBSEARCH) { + $bases[$base][]= $m[1].":dn:=".$m[2]; + } else { + $bases[$matches[2].",$base"][]= $m[1].":dn:=".$m[2]; + } } } } @@ -69,11 +70,15 @@ class filterLDAP { // Switch to new base and search $ldap->cd($base); - $dnFilter= "(|"; - foreach ($dnFilters as $df) { - $dnFilter.= "($df)"; + if (is_array($dnFilters)){ + $dnFilter= "(|"; + foreach ($dnFilters as $df) { + $dnFilter.= "($df)"; + } + $dnFilter.= ")"; + } else { + $dnFilter= ""; } - $dnFilter.= ")"; $ldap->search ("(&$filter$dnFilter)", $attributes); // Check for size limit exceeded messages for GUI feedback