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 <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-11-28 15:20:03 +01:00
parent 3ecdb61998
commit 8888d5a9ad
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 10 additions and 0 deletions

View File

@ -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();
}
}