diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-11 17:22:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-11 17:22:00 +0100 |
commit | 9898ec95c1eeebbcae70329c76c9198298df3c4d (patch) | |
tree | 8da960b794c2f3f483d57555acd52d728b2093e4 /apps/user_ldap | |
parent | 33b82f34be55bb5705222d7c146546ae54a29212 (diff) | |
parent | f84ec9256367758b65f37db5f0bc81a9ed2b8d13 (diff) | |
download | nextcloud-server-9898ec95c1eeebbcae70329c76c9198298df3c4d.tar.gz nextcloud-server-9898ec95c1eeebbcae70329c76c9198298df3c4d.zip |
Merge pull request #7796 from nextcloud/ldap-sync-fixes
LDAP Sync fixes: revert recursion resolution, fixed handling of pagingsize of 0
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 13 | ||||
-rw-r--r-- | apps/user_ldap/lib/Jobs/Sync.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/tests/Jobs/SyncTest.php | 4 |
3 files changed, 11 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 14d5b826f63..b84f5a38b31 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -52,6 +52,7 @@ use OCA\User_LDAP\Mapping\AbstractMapping; use OC\ServerNotAvailableException; use OCP\IConfig; +use OCP\Util; /** * Class Access @@ -1913,11 +1914,8 @@ class Access extends LDAPUtility implements IUserTools { // no cookie known from a potential previous search. We need // to start from 0 to come to the desired page. cookie value // of '0' is valid, because 389ds - $reOffset = 0; - while($reOffset < $offset) { - $this->search($filter, array($base), $attr, $limit, $reOffset, true); - $reOffset += $limit; - } + $reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit; + $this->search($filter, array($base), $attr, $limit, $reOffset, true); $cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset); //still no cookie? obviously, the server does not like us. Let's skip paging efforts. // '0' is valid, because 389ds @@ -1937,9 +1935,8 @@ class Access extends LDAPUtility implements IUserTools { } \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG); } else { - \OCP\Util::writeLog('user_ldap', - 'No paged search for us, Cpt., Limit '.$limit.' Offset '.$offset, - \OCP\Util::INFO); + $e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset); + \OC::$server->getLogger()->logException($e, ['level' => Util::DEBUG]); } } diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index b78a1947e27..0cc0be7d3ca 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -176,10 +176,10 @@ class Sync extends TimedJob { true ); - if($connection->ldapPagingSize === 0) { - return true; + if((int)$connection->ldapPagingSize === 0) { + return false; } - return count($results) >= $connection->ldapPagingSize; + return count($results) >= (int)$connection->ldapPagingSize; } /** diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index f8852a46664..75ffd0e8280 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -158,7 +158,9 @@ class SyncTest extends TestCase { return [ [ 3, 3, true ], [ 3, 5, true ], - [ 3, 2, false] + [ 3, 2, false], + [ 0, 4, false], + [ null, 4, false] ]; } |