LdapInvalidUuids.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\User_LDAP\SetupChecks;
  8. use OCA\User_LDAP\Mapping\GroupMapping;
  9. use OCA\User_LDAP\Mapping\UserMapping;
  10. use OCP\IL10N;
  11. use OCP\SetupCheck\ISetupCheck;
  12. use OCP\SetupCheck\SetupResult;
  13. class LdapInvalidUuids implements ISetupCheck {
  14. public function __construct(
  15. private IL10N $l10n,
  16. private UserMapping $userMapping,
  17. private GroupMapping $groupMapping,
  18. ) {
  19. }
  20. public function getCategory(): string {
  21. return 'ldap';
  22. }
  23. public function getName(): string {
  24. return $this->l10n->t('Invalid LDAP UUIDs');
  25. }
  26. public function run(): SetupResult {
  27. if (count($this->userMapping->getList(0, 1, true)) === 0
  28. && count($this->groupMapping->getList(0, 1, true)) === 0) {
  29. return SetupResult::success($this->l10n->t('None found'));
  30. } else {
  31. return SetupResult::warning($this->l10n->t('Invalid UUIDs of LDAP accounts 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.'));
  32. }
  33. }
  34. }