Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make sure used ldap connection resource is always up to date
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed May 24, 2017
commit bd5d12528f1bdf6ab25dda5179ea20a56916a3a2
14 changes: 8 additions & 6 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -972,14 +972,16 @@ private function invokeLDAPMethod() {
* 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;
Expand Down Expand Up @@ -1012,7 +1014,8 @@ private function executeSearch($filter, $base, &$attr = null, $limit = null, $of

$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;
Expand Down Expand Up @@ -1124,11 +1127,10 @@ private function count($filter, $base, $attr = null, $limit = null, $offset = nu
* @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;
}

Expand Down