Skip to content

Commit 9898ec9

Browse files
authored
Merge pull request #7796 from nextcloud/ldap-sync-fixes
LDAP Sync fixes: revert recursion resolution, fixed handling of pagingsize of 0
2 parents 33b82f3 + f84ec92 commit 9898ec9

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

apps/user_ldap/lib/Access.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
use OC\ServerNotAvailableException;
5454
use OCP\IConfig;
55+
use OCP\Util;
5556

5657
/**
5758
* Class Access
@@ -1913,11 +1914,8 @@ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) {
19131914
// no cookie known from a potential previous search. We need
19141915
// to start from 0 to come to the desired page. cookie value
19151916
// of '0' is valid, because 389ds
1916-
$reOffset = 0;
1917-
while($reOffset < $offset) {
1918-
$this->search($filter, array($base), $attr, $limit, $reOffset, true);
1919-
$reOffset += $limit;
1920-
}
1917+
$reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit;
1918+
$this->search($filter, array($base), $attr, $limit, $reOffset, true);
19211919
$cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset);
19221920
//still no cookie? obviously, the server does not like us. Let's skip paging efforts.
19231921
// '0' is valid, because 389ds
@@ -1937,9 +1935,8 @@ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) {
19371935
}
19381936
\OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG);
19391937
} else {
1940-
\OCP\Util::writeLog('user_ldap',
1941-
'No paged search for us, Cpt., Limit '.$limit.' Offset '.$offset,
1942-
\OCP\Util::INFO);
1938+
$e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset);
1939+
\OC::$server->getLogger()->logException($e, ['level' => Util::DEBUG]);
19431940
}
19441941

19451942
}

apps/user_ldap/lib/Jobs/Sync.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ public function runCycle($cycleData) {
176176
true
177177
);
178178

179-
if($connection->ldapPagingSize === 0) {
180-
return true;
179+
if((int)$connection->ldapPagingSize === 0) {
180+
return false;
181181
}
182-
return count($results) >= $connection->ldapPagingSize;
182+
return count($results) >= (int)$connection->ldapPagingSize;
183183
}
184184

185185
/**

apps/user_ldap/tests/Jobs/SyncTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ public function moreResultsProvider() {
158158
return [
159159
[ 3, 3, true ],
160160
[ 3, 5, true ],
161-
[ 3, 2, false]
161+
[ 3, 2, false],
162+
[ 0, 4, false],
163+
[ null, 4, false]
162164
];
163165
}
164166

0 commit comments

Comments
 (0)