From 8888d5a9ad49f008689490d31eab600afe6fad03 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 28 Nov 2019 15:20:03 +0100 Subject: [PATCH] Add counting to the user backend This will allow reporting to also list the number of SAML users on the instance. Signed-off-by: Roeland Jago Douma --- lib/UserBackend.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/UserBackend.php b/lib/UserBackend.php index a5f5e28..78c3b3e 100644 --- a/lib/UserBackend.php +++ b/lib/UserBackend.php @@ -183,6 +183,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend { $availableActions = \OC\User\Backend::CHECK_PASSWORD; $availableActions |= \OC\User\Backend::GET_DISPLAYNAME; $availableActions |= \OC\User\Backend::GET_HOME; + $availableActions |= \OC\User\Backend::COUNT_USERS; return (bool)($availableActions & $actions); } @@ -733,4 +734,13 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend { return strtoupper($hex_guid_to_guid_str); } + + public function countUsers() { + $query = $this->db->getQueryBuilder(); + $query->select($query->func()->count('uid')) + ->from('user_saml_users'); + $result = $query->execute(); + + return $result->fetchColumn(); + } }