2022-02-08 15:31:32 -05:00
< ? php
declare ( strict_types = 1 );
/**
* @ copyright Copyright ( c ) 2022 Arthur Schiwon < blizzz @ arthur - schiwon . de >
*
* @ author Arthur Schiwon < blizzz @ arthur - schiwon . de >
2023-09-28 05:36:35 -04:00
* @ author Côme Chilliet < come . chilliet @ nextcloud . com >
2022-02-08 15:31:32 -05:00
*
* @ 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 />.
*
*/
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 {
2023-10-16 11:23:47 -04:00
return SetupResult :: warning ( $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.' ));
2023-09-28 05:36:35 -04:00
}
2022-02-08 15:31:32 -05:00
}
}