summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-01-13 12:20:57 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2022-01-14 08:31:40 +0000
commite4235bdebaf623d6ba16abdb04f89a267ad8682d (patch)
treefad178912465d72f5dd8e8fa6eabda4619109053 /apps/user_ldap/lib
parent66ca2925e7985bed851d940da4236f9470be202c (diff)
downloadnextcloud-server-e4235bdebaf623d6ba16abdb04f89a267ad8682d.tar.gz
nextcloud-server-e4235bdebaf623d6ba16abdb04f89a267ad8682d.zip
Fix user_ldap migration for long DNs support
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20211102154716.php78
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20220110154718.php2
2 files changed, 31 insertions, 49 deletions
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
index 7ecf02d8f6f..b359f9fd357 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
@@ -73,11 +73,12 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$changeSchema = true;
}
$column = $table->getColumn('ldap_dn');
- if ($column->getLength() < 4096) {
- $column->setLength(4096);
- $changeSchema = true;
- }
if ($tableName === 'ldap_user_mapping') {
+ if ($column->getLength() < 4096) {
+ $column->setLength(4096);
+ $changeSchema = true;
+ }
+
if ($table->hasIndex('ldap_dn_users')) {
$table->dropIndex('ldap_dn_users');
$changeSchema = true;
@@ -91,50 +92,31 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$changeSchema = true;
}
} else {
- if ($table->hasIndex('owncloud_name_groups')) {
- $table->dropIndex('owncloud_name_groups');
- $changeSchema = true;
- }
- if (!$table->hasIndex('ldap_group_dn_hashes')) {
- $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
- $changeSchema = true;
- }
- if (!$table->hasIndex('ldap_group_directory_uuid')) {
- $table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
- $changeSchema = true;
- }
- if (!$table->hasPrimaryKey()) {
- $table->setPrimaryKey(['owncloud_name']);
- $changeSchema = true;
- }
-
- if ($table->getPrimaryKeyColumns() !== ['owncloud_name']) {
- // We need to copy the table twice to be able to change primary key, prepare the backup table
- $table2 = $schema->createTable('ldap_group_mapping_backup');
- $table2->addColumn('ldap_dn', Types::STRING, [
- 'notnull' => true,
- 'length' => 255,
- 'default' => '',
- ]);
- $table2->addColumn('owncloud_name', Types::STRING, [
- 'notnull' => true,
- 'length' => 64,
- 'default' => '',
- ]);
- $table2->addColumn('directory_uuid', Types::STRING, [
- 'notnull' => true,
- 'length' => 255,
- 'default' => '',
- ]);
- $table2->addColumn('ldap_dn_hash', Types::STRING, [
- 'notnull' => false,
- 'length' => 64,
- ]);
- $table2->setPrimaryKey(['owncloud_name']);
- $table2->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
- $table2->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
- $changeSchema = true;
- }
+ // We need to copy the table twice to be able to change primary key, prepare the backup table
+ $table2 = $schema->createTable('ldap_group_mapping_backup');
+ $table2->addColumn('ldap_dn', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 4096,
+ 'default' => '',
+ ]);
+ $table2->addColumn('owncloud_name', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ 'default' => '',
+ ]);
+ $table2->addColumn('directory_uuid', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 255,
+ 'default' => '',
+ ]);
+ $table2->addColumn('ldap_dn_hash', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 64,
+ ]);
+ $table2->setPrimaryKey(['owncloud_name'], 'lgm_backup_primary');
+ $table2->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
+ $table2->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
+ $changeSchema = true;
}
}
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
index caadd9d9be2..5f146ab06a5 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
@@ -54,7 +54,7 @@ class Version1130Date20220110154718 extends GroupMappingMigration {
$table = $schema->createTable('ldap_group_mapping');
$table->addColumn('ldap_dn', Types::STRING, [
'notnull' => true,
- 'length' => 255,
+ 'length' => 4096,
'default' => '',
]);
$table->addColumn('owncloud_name', Types::STRING, [