aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/User
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-10-10 13:33:49 +0200
committerGitHub <noreply@github.com>2023-10-10 13:33:49 +0200
commit43971f6a5cd833895a28293e62d55c6eb60117dc (patch)
tree979233cc0550768fa302337ed62a4d31f6530754 /lib/private/User
parent025cdb35cb58c854c9875748a5efd24ac1f312e3 (diff)
parente51d20479e70320486385a4787f5d09abdd6ed4e (diff)
downloadnextcloud-server-43971f6a5cd833895a28293e62d55c6eb60117dc.tar.gz
nextcloud-server-43971f6a5cd833895a28293e62d55c6eb60117dc.zip
Merge pull request #39756 from nextcloud/enh/add-disabled-users-endpoint
Add endpoint for getting disabled user list
Diffstat (limited to 'lib/private/User')
-rw-r--r--lib/private/User/Manager.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index fb1afb65825..8ec8ef0c4be 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -52,6 +52,7 @@ use OCP\User\Backend\IGetRealUIDBackend;
use OCP\User\Backend\ISearchKnownUsersBackend;
use OCP\User\Backend\ICheckPasswordBackend;
use OCP\User\Backend\ICountUsersBackend;
+use OCP\User\Backend\IProvideEnabledStateBackend;
use OCP\User\Events\BeforeUserCreatedEvent;
use OCP\User\Events\UserCreatedEvent;
use OCP\UserInterface;
@@ -338,6 +339,35 @@ class Manager extends PublicEmitter implements IUserManager {
}
/**
+ * @return IUser[]
+ */
+ public function getDisabledUsers(?int $limit = null, int $offset = 0): array {
+ $users = $this->config->getUsersForUserValue('core', 'enabled', 'false');
+ $users = array_combine(
+ $users,
+ array_map(
+ fn (string $uid): IUser => new LazyUser($uid, $this),
+ $users
+ )
+ );
+
+ $tempLimit = ($limit === null ? null : $limit + $offset);
+ foreach ($this->backends as $backend) {
+ if (($tempLimit !== null) && (count($users) >= $tempLimit)) {
+ break;
+ }
+ if ($backend instanceof IProvideEnabledStateBackend) {
+ $backendUsers = $backend->getDisabledUserList(($tempLimit === null ? null : $tempLimit - count($users)));
+ foreach ($backendUsers as $uid) {
+ $users[$uid] = new LazyUser($uid, $this, null, $backend);
+ }
+ }
+ }
+
+ return array_slice($users, $offset, $limit);
+ }
+
+ /**
* Search known users (from phonebook sync) by displayName
*
* @param string $searcher