}
return [];
}
-
+
/**
* Set password for an LDAP user identified by a DN
*
if ($this->ncUserManager instanceof PublicEmitter && $isUser) {
$this->cacheUserExists($name);
$this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]);
+ } elseif (!$isUser) {
+ $this->cacheGroupExists($name);
}
return true;
}
$this->connection->writeToCache('userExists'.$ocName, true);
}
+ /**
+ * caches a group as existing
+ */
+ public function cacheGroupExists(string $gid): void {
+ $this->connection->writeToCache('groupExists'.$gid, true);
+ }
+
/**
* caches the user display name
* @param string $ocName the internal Nextcloud username
* @return array
*/
public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) {
- return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), $this->manyAttributes($attr));
+ $groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
+ array_walk($groupRecords, function($record) {
+ $newlyMapped = false;
+ $gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record);
+ if(!$newlyMapped && is_string($gid)) {
+ $this->cacheGroupExists($gid);
+ }
+ });
+ return $this->fetchList($groupRecords, $this->manyAttributes($attr));
}
/**