2022-02-08 15:31:32 -05:00
< ? php
declare ( strict_types = 1 );
/**
2024-05-29 05:32:54 -04:00
* SPDX - FileCopyrightText : 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX - License - Identifier : AGPL - 3.0 - or - later
2022-02-08 15:31:32 -05:00
*/
2022-05-30 03:59:52 -04:00
namespace OCA\User_LDAP\SetupChecks ;
2022-02-08 15:31:32 -05:00
use OCA\User_LDAP\Mapping\GroupMapping ;
use OCA\User_LDAP\Mapping\UserMapping ;
use OCP\IL10N ;
2022-05-30 03:59:52 -04:00
use OCP\SetupCheck\ISetupCheck ;
2023-09-28 05:36:35 -04:00
use OCP\SetupCheck\SetupResult ;
2022-02-08 15:31:32 -05:00
2022-05-30 03:59:52 -04:00
class LdapInvalidUuids implements ISetupCheck {
2023-09-28 10:15:00 -04:00
public function __construct (
private IL10N $l10n ,
private UserMapping $userMapping ,
private GroupMapping $groupMapping ,
) {
2022-05-30 03:59:52 -04:00
}
public function getCategory () : string {
return 'ldap' ;
2022-02-08 15:31:32 -05:00
}
2023-09-28 05:36:35 -04:00
public function getName () : string {
2023-10-24 05:40:03 -04:00
return $this -> l10n -> t ( 'Invalid LDAP UUIDs' );
2022-02-08 15:31:32 -05:00
}
2023-09-28 05:36:35 -04:00
public function run () : SetupResult {
if ( count ( $this -> userMapping -> getList ( 0 , 1 , true )) === 0
&& count ( $this -> groupMapping -> getList ( 0 , 1 , true )) === 0 ) {
2023-10-24 05:40:03 -04:00
return SetupResult :: success ( $this -> l10n -> t ( 'None found' ));
2023-09-28 05:36:35 -04:00
} else {
2022-09-21 11:44:32 -04:00
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.' ));
2023-09-28 05:36:35 -04:00
}
2022-02-08 15:31:32 -05:00
}
}