summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-03-20 13:58:08 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-03-20 13:58:08 +0100
commit057c2638e4d1c369f03739faad02d9d6c87e83f7 (patch)
treee96e1e77989953516f5b83e4b615b369f30b2128
parent5747e0e3f98d3c299b0bd46bb77ca7bf6b170312 (diff)
downloadnextcloud-server-057c2638e4d1c369f03739faad02d9d6c87e83f7.tar.gz
nextcloud-server-057c2638e4d1c369f03739faad02d9d6c87e83f7.zip
LDAP Wizard: when determining objectclasses, we realy do not need to look at every entry. Fixes #7530
-rw-r--r--apps/user_ldap/lib/wizard.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index e79090febc1..930db5c4743 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -869,12 +869,14 @@ class Wizard extends LDAPUtility {
* @param string $attr the attribute of which a list of values shall be returned
* @param $lfw bool, whether the last filter is a wildcard which shall not
* be processed if there were already findings, defaults to true
+ * @param int $dnReadLimit the amount of how many DNs should be analyzed.
+ * The lower, the faster
* @param string $maxF string. if not null, this variable will have the filter that
* yields most result entries
* @return mixed, an array with the values on success, false otherwise
*
*/
- private function cumulativeSearchOnAttribute($filters, $attr, $lfw = true, &$maxF = null) {
+ private function cumulativeSearchOnAttribute($filters, $attr, $lfw = true, $dnReadLimit = 5, &$maxF = null) {
$dnRead = array();
$foundItems = array();
$maxEntries = 0;
@@ -902,6 +904,7 @@ class Wizard extends LDAPUtility {
$maxEntries = $entries;
$maxF = $filter;
}
+ $dnReadCount = 0;
do {
$entry = $this->ldap->$getEntryFunc($cr, $rr);
if(!$this->ldap->isResource($entry)) {
@@ -916,13 +919,15 @@ class Wizard extends LDAPUtility {
$state = $this->getAttributeValuesFromEntry($attributes,
$attr,
$newItems);
+ $dnReadCount++;
$foundItems = array_merge($foundItems, $newItems);
$this->resultCache[$dn][$attr] = $newItems;
$dnRead[] = $dn;
$getEntryFunc = 'nextEntry';
$rr = $entry; //will be expected by nextEntry next round
- } while($state === self::LRESULT_PROCESSED_SKIP
- || $this->ldap->isResource($entry));
+ } while(($state === self::LRESULT_PROCESSED_SKIP
+ || $this->ldap->isResource($entry))
+ && ($dnReadLimit === 0 || $dnReadCount <= $dnReadLimit));
}
}
@@ -950,9 +955,19 @@ class Wizard extends LDAPUtility {
$objectclasses[$key] = $p.$value;
}
$maxEntryObjC = '';
+
+ //how deep to dig?
+ //When looking for objectclasses, testing few entries is sufficient,
+ //when looking for group we need to get all names, though.
+ if(strtolower($attr) === 'objectclass') {
+ $dig = 5;
+ } else {
+ $dig = 0;
+ }
+
$availableFeatures =
$this->cumulativeSearchOnAttribute($objectclasses, $attr,
- true, $maxEntryObjC);
+ true, $dig, $maxEntryObjC);
if(is_array($availableFeatures)
&& count($availableFeatures) > 0) {
natcasesort($availableFeatures);