aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/User
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-08-08 14:54:40 +0200
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-10-09 12:04:35 +0200
commita1255539b838b89f7946ce9b819678e7d2057759 (patch)
tree9748d5f2f84163e157f871161e5023717c0da9ff /lib/private/User
parent06efe9f211f36798d970e57040bf5fb49086cdf6 (diff)
downloadnextcloud-server-a1255539b838b89f7946ce9b819678e7d2057759.tar.gz
nextcloud-server-a1255539b838b89f7946ce9b819678e7d2057759.zip
Add endpoint for getting disabled user list
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
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