summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-05-25 00:45:48 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-05-25 00:45:48 +0200
commitbd5d12528f1bdf6ab25dda5179ea20a56916a3a2 (patch)
tree06fe95a3189989110a4fc2eca6a40e01f12e07f7 /apps
parent8c89bf7c59bf82d9a4103a658100a1b6e248c1aa (diff)
downloadnextcloud-server-bd5d12528f1bdf6ab25dda5179ea20a56916a3a2.tar.gz
nextcloud-server-bd5d12528f1bdf6ab25dda5179ea20a56916a3a2.zip
make sure used ldap connection resource is always up to date
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/Access.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index a3c40ceb241..9293ae786bf 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -972,14 +972,16 @@ class Access extends LDAPUtility implements IUserTools {
* This was enough to get solr indexer working which has large delays between LDAP fetches.
*/
\OCP\Util::writeLog('user_ldap', "Connection lost on $command, attempting to reestablish.", \OCP\Util::DEBUG);
- $this->connection = clone $this->connection;
+ $this->connection->resetConnectionResource();
$cr = $this->connection->getConnectionResource();
+
if(!$this->ldap->isResource($cr)) {
// Seems like we didn't find any resource.
\OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", \OCP\Util::DEBUG);
- return false;
+ throw $e;
}
- $arguments[0] = $cr;
+
+ $arguments[0] = array_pad([], count($arguments[0]), $cr);
$ret = $doMethod();
}
return $ret;
@@ -1012,7 +1014,8 @@ class Access extends LDAPUtility implements IUserTools {
$linkResources = array_pad(array(), count($base), $cr);
$sr = $this->invokeLDAPMethod('search', $linkResources, $base, $filter, $attr);
- $error = $this->ldap->errno($cr);
+ // cannot use $cr anymore, might have changed in the previous call!
+ $error = $this->ldap->errno($this->connection->getConnectionResource());
if(!is_array($sr) || $error !== 0) {
\OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), \OCP\Util::ERROR);
return false;
@@ -1124,11 +1127,10 @@ class Access extends LDAPUtility implements IUserTools {
* @return int
*/
private function countEntriesInSearchResults($searchResults) {
- $cr = $this->connection->getConnectionResource();
$counter = 0;
foreach($searchResults as $res) {
- $count = intval($this->invokeLDAPMethod('countEntries', $cr, $res));
+ $count = intval($this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res));
$counter += $count;
}