aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-05-30 09:59:52 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-10-19 11:43:58 +0200
commitc71e47f5c311836973c7ae22b174dfbbf8117304 (patch)
tree17ffa6b2cea8b0da7b791bc34daed4ecb5284465 /apps/user_ldap/lib
parenteb1d612d961b562e744b8c6d8d361075b6daad55 (diff)
downloadnextcloud-server-c71e47f5c311836973c7ae22b174dfbbf8117304.tar.gz
nextcloud-server-c71e47f5c311836973c7ae22b174dfbbf8117304.zip
Progress
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/AppInfo/Application.php2
-rw-r--r--apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php64
2 files changed, 66 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php
index 1b6c8cab0fd..459de751812 100644
--- a/apps/user_ldap/lib/AppInfo/Application.php
+++ b/apps/user_ldap/lib/AppInfo/Application.php
@@ -43,6 +43,7 @@ use OCA\User_LDAP\Notification\Notifier;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User_Proxy;
use OCA\User_LDAP\UserPluginManager;
+use OCA\User_LDAP\SetupChecks\LdapInvalidUuids;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -116,6 +117,7 @@ class Application extends App implements IBootstrap {
false
);
$context->registerEventListener(PostLoginEvent::class, LoginListener::class);
+ $context->registerSetupCheck(LdapInvalidUuids::class);
}
public function boot(IBootContext $context): void {
diff --git a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php
new file mode 100644
index 00000000000..f8c8a5f1fc5
--- /dev/null
+++ b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php
@@ -0,0 +1,64 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2022 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\User_LDAP\SetupChecks;
+
+use OCA\User_LDAP\Mapping\GroupMapping;
+use OCA\User_LDAP\Mapping\UserMapping;
+use OCP\App\IAppManager;
+use OCP\IL10N;
+use OCP\IServerContainer;
+use OCP\SetupCheck\ISetupCheck;
+
+class LdapInvalidUuids implements ISetupCheck {
+ private IL10N $l10n;
+ private IServerContainer $server;
+ private UserMapping $userMapping;
+ private GroupMapping $groupMapping;
+
+ public function __construct(IL10N $l10n, UserMapping $userMapping, GroupMapping $groupMapping) {
+ $this->l10n = $l10n;
+ $this->userMapping = $userMapping;
+ $this->groupMapping = $groupMapping;
+ }
+
+ public function getCategory(): string {
+ return 'ldap';
+ }
+
+ public function description(): string {
+ return $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.');
+ }
+
+ public function severity(): string {
+ return 'warning';
+ }
+
+ public function run(): bool {
+ return count($this->userMapping->getList(0, 1, true)) === 0
+ && count($this->groupMapping->getList(0, 1, true)) === 0;
+ }
+}