index 5a6701d65540462693a5b681e7b475167d8e2a60..34aff04a8e5652b6c00a9e61cb5bdb8df7dbb459 100644 (file)
class filterLDAP {
class filterLDAP {
- static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+ static function query($base, $scope, $filter, $attributes, $category, $objectStorage= array(""))
{
$config= session::global_get('config');
$ldap= $config->get_ldap_link(TRUE);
{
$config= session::global_get('config');
$ldap= $config->get_ldap_link(TRUE);
if (!is_array($category)) {
$category= array($category);
}
if (!is_array($category)) {
$category= array($category);
}
- if (!is_array($objectStorage)) {
- $objectStorage= array($objectStorage);
- }
+
+ // Store in base - i.e. is a rdn value empty?
+ $storeOnBase= count($objectStorage) == 1 && empty($objectStorage[0]);
+
+ $method= ($storeOnBase && !($flags & GL_SUBSEARCH))?"ls":"search";
// Initialize search bases
$bases= array();
// Get list of sub bases to search on
// Initialize search bases
$bases= array();
// Get list of sub bases to search on
- if (count($objectStorage) == 0) {
+ if ($storeOnBase) {
$bases[$base]= "";
} else {
foreach ($objectStorage as $oc) {
$oc= preg_replace('/,$/', '', $oc);
$bases[$base]= "";
} else {
foreach ($objectStorage as $oc) {
$oc= preg_replace('/,$/', '', $oc);
- $tmp= split(',', $oc);
+ $tmp= explode(',', $oc);
if (count($tmp) == 1) {
preg_match('/([^=]+)=(.*)$/', $oc, $m);
if ($flags & GL_SUBSEARCH) {
if (count($tmp) == 1) {
preg_match('/([^=]+)=(.*)$/', $oc, $m);
if ($flags & GL_SUBSEARCH) {
}
// Switch to new base and search
}
// Switch to new base and search
- $ldap->cd($base);
if (is_array($dnFilters)){
$dnFilter= "(|";
foreach ($dnFilters as $df) {
if (is_array($dnFilters)){
$dnFilter= "(|";
foreach ($dnFilters as $df) {
} else {
$dnFilter= "";
}
} else {
$dnFilter= "";
}
- $ldap->search ("(&$filter$dnFilter)", $attributes);
+ $ldap->cd($base);
+ if ($method == "ls") {
+ $ldap->ls("(&$filter$dnFilter)", $base, $attributes);
+ } else {
+ $ldap->search("(&$filter$dnFilter)", $attributes);
+ }
// Check for size limit exceeded messages for GUI feedback
if (preg_match("/size limit/i", $ldap->get_error())){
// Check for size limit exceeded messages for GUI feedback
if (preg_match("/size limit/i", $ldap->get_error())){