summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-10-25 11:16:01 +0200
committerGitHub <noreply@github.com>2022-10-25 11:16:01 +0200
commit91392c08d6d69d74431588a9f38cbf15ef41c937 (patch)
tree7f7c6a7bc04e1dc5592582635abb91698dfd7dbc /apps
parente3aac7d573961933b185c87d9600580b21423a42 (diff)
parent8b7f6a80c306b7f6defba376ec713a94cbbbe1bf (diff)
downloadnextcloud-server-91392c08d6d69d74431588a9f38cbf15ef41c937.tar.gz
nextcloud-server-91392c08d6d69d74431588a9f38cbf15ef41c937.zip
Merge pull request #34774 from nextcloud/fix/fair-use-ldap-fix
Expose mapped user count from LDAP and use that for user limit check
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/User_LDAP.php9
-rw-r--r--apps/user_ldap/lib/User_Proxy.php18
2 files changed, 24 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 5a445100052..650c974da81 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -45,14 +45,15 @@ use OCA\User_LDAP\Exceptions\NotOnLDAP;
use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
+use OCP\IUserBackend;
use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager;
+use OCP\User\Backend\ICountMappedUsersBackend;
use OCP\User\Backend\ICountUsersBackend;
-use OCP\IUserBackend;
use OCP\UserInterface;
use Psr\Log\LoggerInterface;
-class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend {
+class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend {
/** @var \OCP\IConfig */
protected $ocConfig;
@@ -598,6 +599,10 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
return $entries;
}
+ public function countMappedUsers(): int {
+ return $this->access->getUserMapper()->count();
+ }
+
/**
* Backend name to be shown in user management
* @return string the name of the backend to be shown
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 93420bbb470..b98fa8da0ff 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -33,11 +33,14 @@ namespace OCA\User_LDAP;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
+use OCP\IUserBackend;
use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager;
+use OCP\User\Backend\ICountMappedUsersBackend;
use OCP\User\Backend\ICountUsersBackend;
+use OCP\UserInterface;
-class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP, ICountUsersBackend {
+class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend {
private $backends = [];
/** @var User_LDAP */
private $refBackend = null;
@@ -390,6 +393,19 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
}
/**
+ * Count the number of mapped users
+ */
+ public function countMappedUsers(): int {
+ $this->setup();
+
+ $users = 0;
+ foreach ($this->backends as $backend) {
+ $users += $backend->countMappedUsers();
+ }
+ return $users;
+ }
+
+ /**
* Return access for LDAP interaction.
*
* @param string $uid