Merge pull request #7796 from nextcloud/ldap-sync-fixes

LDAP Sync fixes: revert recursion resolution, fixed handling of pagingsize of 0
This commit is contained in:
Morris Jobke 2018-01-11 17:22:00 +01:00 committed by GitHub
commit 9898ec95c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View File

@ -52,6 +52,7 @@ use OCA\User_LDAP\Mapping\AbstractMapping;
use OC\ServerNotAvailableException; use OC\ServerNotAvailableException;
use OCP\IConfig; use OCP\IConfig;
use OCP\Util;
/** /**
* Class Access * Class Access
@ -1913,11 +1914,8 @@ class Access extends LDAPUtility implements IUserTools {
// no cookie known from a potential previous search. We need // no cookie known from a potential previous search. We need
// to start from 0 to come to the desired page. cookie value // to start from 0 to come to the desired page. cookie value
// of '0' is valid, because 389ds // of '0' is valid, because 389ds
$reOffset = 0; $reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit;
while($reOffset < $offset) { $this->search($filter, array($base), $attr, $limit, $reOffset, true);
$this->search($filter, array($base), $attr, $limit, $reOffset, true);
$reOffset += $limit;
}
$cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset); $cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset);
//still no cookie? obviously, the server does not like us. Let's skip paging efforts. //still no cookie? obviously, the server does not like us. Let's skip paging efforts.
// '0' is valid, because 389ds // '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); \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG);
} else { } else {
\OCP\Util::writeLog('user_ldap', $e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset);
'No paged search for us, Cpt., Limit '.$limit.' Offset '.$offset, \OC::$server->getLogger()->logException($e, ['level' => Util::DEBUG]);
\OCP\Util::INFO);
} }
} }

View File

@ -176,10 +176,10 @@ class Sync extends TimedJob {
true true
); );
if($connection->ldapPagingSize === 0) { if((int)$connection->ldapPagingSize === 0) {
return true; return false;
} }
return count($results) >= $connection->ldapPagingSize; return count($results) >= (int)$connection->ldapPagingSize;
} }
/** /**

View File

@ -158,7 +158,9 @@ class SyncTest extends TestCase {
return [ return [
[ 3, 3, true ], [ 3, 3, true ],
[ 3, 5, true ], [ 3, 5, true ],
[ 3, 2, false] [ 3, 2, false],
[ 0, 4, false],
[ null, 4, false]
]; ];
} }