aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-12-07 17:49:33 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-12-07 17:49:33 +0100
commit991190b9946442c685d5d58530fe602e008f9a4b (patch)
treeb1e5ca9c730e25ef23f5f24d90dbc13537396cfa /apps/user_ldap/lib
parent7d529c081a5b379b7058d194970dc79c3b49357f (diff)
downloadnextcloud-server-991190b9946442c685d5d58530fe602e008f9a4b.tar.gz
nextcloud-server-991190b9946442c685d5d58530fe602e008f9a4b.zip
ensure that users are cached when they are retrieved
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Access.php17
-rw-r--r--apps/user_ldap/lib/Helper.php2
2 files changed, 12 insertions, 7 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 07583798e46..d1c738719b1 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -830,6 +830,7 @@ class Access extends LDAPUtility implements IUserTools {
$recordsToUpdate = array_filter($ldapRecords, function($record) use ($isBackgroundJobModeAjax) {
$newlyMapped = false;
$uid = $this->dn2ocname($record['dn'][0], null, true, $newlyMapped, $record);
+ $this->cacheUserExists($uid);
return ($uid !== false) && ($newlyMapped || $isBackgroundJobModeAjax);
});
}
@@ -854,7 +855,6 @@ class Access extends LDAPUtility implements IUserTools {
if($ocName === false) {
continue;
}
- $this->cacheUserExists($ocName);
$user = $this->userManager->get($ocName);
if($user instanceof OfflineUser) {
$user->unmark();
@@ -1019,11 +1019,15 @@ class Access extends LDAPUtility implements IUserTools {
/**
* retrieved. Results will according to the order in the array.
+ *
+ * @param $filter
+ * @param $base
+ * @param null $attr
* @param int $limit optional, maximum results to be counted
* @param int $offset optional, a starting point
* @return array|false array with the search result as first value and pagedSearchOK as
* second | false if not successful
- * @throws \OC\ServerNotAvailableException
+ * @throws ServerNotAvailableException
*/
private function executeSearch($filter, $base, &$attr = null, $limit = null, $offset = null) {
if(!is_null($attr) && !is_array($attr)) {
@@ -1169,6 +1173,7 @@ class Access extends LDAPUtility implements IUserTools {
/**
* Executes an LDAP search
+ *
* @param string $filter the LDAP filter for the search
* @param array $base an array containing the LDAP subtree(s) that shall be searched
* @param string|string[] $attr optional, array, one or more attributes that shall be
@@ -1176,6 +1181,7 @@ class Access extends LDAPUtility implements IUserTools {
* @param int $offset
* @param bool $skipHandling
* @return array with the search result
+ * @throws ServerNotAvailableException
*/
public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
$limitPerPage = intval($this->connection->ldapPagingSize);
@@ -1189,12 +1195,12 @@ class Access extends LDAPUtility implements IUserTools {
* loops through until we get $continue equals true and
* $findings['count'] < $limit
*/
- $findings = array();
+ $findings = [];
$savedoffset = $offset;
do {
$search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset);
if($search === false) {
- return array();
+ return [];
}
list($sr, $pagedSearchOK) = $search;
$cr = $this->connection->getConnectionResource();
@@ -1231,7 +1237,7 @@ class Access extends LDAPUtility implements IUserTools {
}
if(!is_null($attr)) {
- $selection = array();
+ $selection = [];
$i = 0;
foreach($findings as $item) {
if(!is_array($item)) {
@@ -1239,7 +1245,6 @@ class Access extends LDAPUtility implements IUserTools {
}
$item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8');
foreach($attr as $key) {
- $key = mb_strtolower($key, 'UTF-8');
if(isset($item[$key])) {
if(is_array($item[$key]) && isset($item[$key]['count'])) {
unset($item[$key]['count']);
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php
index a433ea8e4a7..3157a7ab09d 100644
--- a/apps/user_ldap/lib/Helper.php
+++ b/apps/user_ldap/lib/Helper.php
@@ -229,7 +229,7 @@ class Helper {
/**
* sanitizes a DN received from the LDAP server
* @param array $dn the DN in question
- * @return array the sanitized DN
+ * @return array|string the sanitized DN
*/
public function sanitizeDN($dn) {
//treating multiple base DNs