|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright Copyright (c) 2022 Arthur Schiwon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @author Arthur Schiwon <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OCA\Settings\SetupChecks; |
|
28
|
|
|
|
|
29
|
|
|
use OCA\User_LDAP\Mapping\GroupMapping; |
|
30
|
|
|
use OCA\User_LDAP\Mapping\UserMapping; |
|
31
|
|
|
use OCP\App\IAppManager; |
|
32
|
|
|
use OCP\IL10N; |
|
33
|
|
|
use OCP\IServerContainer; |
|
34
|
|
|
|
|
35
|
|
|
class LdapInvalidUuids { |
|
36
|
|
|
|
|
37
|
|
|
/** @var IAppManager */ |
|
38
|
|
|
private $appManager; |
|
39
|
|
|
/** @var IL10N */ |
|
40
|
|
|
private $l10n; |
|
41
|
|
|
/** @var IServerContainer */ |
|
42
|
|
|
private $server; |
|
43
|
|
|
|
|
44
|
|
|
public function __construct(IAppManager $appManager, IL10N $l10n, IServerContainer $server) { |
|
45
|
|
|
$this->appManager = $appManager; |
|
46
|
|
|
$this->l10n = $l10n; |
|
47
|
|
|
$this->server = $server; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function description(): string { |
|
51
|
|
|
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.'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function severity(): string { |
|
55
|
|
|
return 'warning'; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function run(): bool { |
|
59
|
|
|
if (!$this->appManager->isEnabledForUser('user_ldap')) { |
|
60
|
|
|
return true; |
|
61
|
|
|
} |
|
62
|
|
|
/** @var UserMapping $userMapping */ |
|
63
|
|
|
$userMapping = $this->server->get(UserMapping::class); |
|
64
|
|
|
/** @var GroupMapping $groupMapping */ |
|
65
|
|
|
$groupMapping = $this->server->get(GroupMapping::class); |
|
66
|
|
|
return count($userMapping->getList(0, 1, true)) === 0 |
|
67
|
|
|
&& count($groupMapping->getList(0, 1, true)) === 0; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|