Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(LDAP): add migration step to set and clean up config value
- *ldap_mark_remnants_as_disabled were old values and removed now, after
- combining their value and storing into current
  backend_mark_remnants_as_disabled

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Jul 16, 2025
commit 7b6bdaa6b5eb54ed0ae5cfd20719a3ebecc6a974
3 changes: 2 additions & 1 deletion apps/user_ldap/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
A user logs into Nextcloud with their LDAP or AD credentials, and is granted access based on an authentication request handled by the LDAP or AD server. Nextcloud does not store LDAP or AD passwords, rather these credentials are used to authenticate a user and then Nextcloud uses a session for the user ID. More information is available in the LDAP User and Group Backend documentation.

</description>
<version>1.23.0</version>
<version>1.23.1</version>
<licence>agpl</licence>
<author>Dominik Schmidt</author>
<author>Arthur Schiwon</author>
Expand Down Expand Up @@ -42,6 +42,7 @@ A user logs into Nextcloud with their LDAP or AD credentials, and is granted acc
<post-migration>
<step>OCA\User_LDAP\Migration\UUIDFixInsert</step>
<step>OCA\User_LDAP\Migration\RemoveRefreshTime</step>
<step>OCA\User_LDAP\Migration\RearrangeMarkRemnantsAsDisabled</step>
</post-migration>
<install>
<step>OCA\User_LDAP\Migration\SetDefaultProvider</step>
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'OCA\\User_LDAP\\Mapping\\GroupMapping' => $baseDir . '/../lib/Mapping/GroupMapping.php',
'OCA\\User_LDAP\\Mapping\\UserMapping' => $baseDir . '/../lib/Mapping/UserMapping.php',
'OCA\\User_LDAP\\Migration\\GroupMappingMigration' => $baseDir . '/../lib/Migration/GroupMappingMigration.php',
'OCA\\User_LDAP\\Migration\\RearrangeMarkRemnantsAsDisabled' => $baseDir . '/../lib/Migration/RearrangeMarkRemnantsAsDisabled.php',
'OCA\\User_LDAP\\Migration\\RemoveRefreshTime' => $baseDir . '/../lib/Migration/RemoveRefreshTime.php',
'OCA\\User_LDAP\\Migration\\SetDefaultProvider' => $baseDir . '/../lib/Migration/SetDefaultProvider.php',
'OCA\\User_LDAP\\Migration\\UUIDFix' => $baseDir . '/../lib/Migration/UUIDFix.php',
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Mapping\\GroupMapping' => __DIR__ . '/..' . '/../lib/Mapping/GroupMapping.php',
'OCA\\User_LDAP\\Mapping\\UserMapping' => __DIR__ . '/..' . '/../lib/Mapping/UserMapping.php',
'OCA\\User_LDAP\\Migration\\GroupMappingMigration' => __DIR__ . '/..' . '/../lib/Migration/GroupMappingMigration.php',
'OCA\\User_LDAP\\Migration\\RearrangeMarkRemnantsAsDisabled' => __DIR__ . '/..' . '/../lib/Migration/RearrangeMarkRemnantsAsDisabled.php',
'OCA\\User_LDAP\\Migration\\RemoveRefreshTime' => __DIR__ . '/..' . '/../lib/Migration/RemoveRefreshTime.php',
'OCA\\User_LDAP\\Migration\\SetDefaultProvider' => __DIR__ . '/..' . '/../lib/Migration/SetDefaultProvider.php',
'OCA\\User_LDAP\\Migration\\UUIDFix' => __DIR__ . '/..' . '/../lib/Migration/UUIDFix.php',
Expand Down
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public function getDefaults(): array {
'ldap_expert_uuid_group_attr' => '',
'has_memberof_filter_support' => 0,
'use_memberof_to_detect_membership' => 1,
'ldap_mark_remnants_as_disabled' => 0,
'backend_mark_remnants_as_disabled' => 0,
'last_jpegPhoto_lookup' => 0,
'ldap_nested_groups' => 0,
'ldap_paging_size' => 500,
Expand Down Expand Up @@ -631,7 +631,7 @@ public function getConfigTranslationArray(): array {
'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr',
'has_memberof_filter_support' => 'hasMemberOfFilterSupport',
'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
'ldap_mark_remnants_as_disabled' => 'markRemnantsAsDisabled',
'backend_mark_remnants_as_disabled' => 'markRemnantsAsDisabled',
'last_jpegPhoto_lookup' => 'lastJpegPhotoLookup',
'ldap_nested_groups' => 'ldapNestedGroups',
'ldap_paging_size' => 'ldapPagingSize',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\User_LDAP\Migration;

use OCP\IAppConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class RearrangeMarkRemnantsAsDisabled implements IRepairStep {
public function __construct(
protected IAppConfig $appConfig,
protected IDBConnection $dbc,
) {

}
public function getName(): string {
return 'Rearrange the configuration of ldap_mark_remnants_as_disabled';
}

public function run(IOutput $output): void {
$allKeys = $this->appConfig->getKeys('user_ldap');

if (in_array('backend_mark_remnants_as_disabled', $allKeys, true)) {
return;
}

// if it was enabled for at least one configuration, use it as global configuration
$filteredKeys = array_filter($allKeys, static function (string $key): bool {
return str_ends_with($key, 'ldap_mark_remnants_as_disabled');
});
$newValue = false;
foreach ($filteredKeys as $filteredKey) {
$newValue = $newValue || $this->appConfig->getValueBool('user_ldap', $filteredKey);
}

// set the new value
$this->appConfig->setValueBool('user_ldap', 'backend_mark_remnants_as_disabled', $newValue);
if ($newValue) {
$output->info('The option "Disable missing users from LDAP" is activated.');
}

// clean up now that the new value is saved
foreach ($filteredKeys as $filteredKey) {
$this->appConfig->deleteKey('user_ldap', $filteredKey);
}
}
}
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Settings/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getAuthorizedAppConfig(): array {

public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('config', [
'ldap_mark_remnants_as_disabled' => $this->appConfig->getValueBool('user_ldap', 'ldap_mark_remnants_as_disabled'),
'backend_mark_remnants_as_disabled' => $this->appConfig->getValueBool('user_ldap', 'backend_mark_remnants_as_disabled'),
]);

return new TemplateResponse('user_ldap', 'settings-global');
Expand Down
4 changes: 2 additions & 2 deletions apps/user_ldap/src/AppSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<NcSettingsSection :name="t('user_ldap', 'Configuration-independent settings')">
<ul class="user_ldap__app-settings-list">
<li>
<NcCheckboxRadioSwitch :checked="config.ldap_mark_remnants_as_disabled"
<NcCheckboxRadioSwitch :checked="config.backend_mark_remnants_as_disabled"
type="switch"
@update:checked="updateBoolSetting('ldap_mark_remnants_as_disabled')">
@update:checked="updateBoolSetting('backend_mark_remnants_as_disabled')">
{{ t('user_ldap', 'Disable users missing from LDAP') }}
</NcCheckboxRadioSwitch>
</li>
Expand Down