summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-27 07:46:19 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-27 15:13:01 +0100
commit334f3943abb2e2f523552a72f5f8034a511ddc21 (patch)
tree828b94802167a1eef95dcd165091c963cf88b812 /apps/user_ldap/lib
parent6c513f8b43e9ed1c4d88447d65d9e6661c12cbca (diff)
downloadnextcloud-server-334f3943abb2e2f523552a72f5f8034a511ddc21.tar.gz
nextcloud-server-334f3943abb2e2f523552a72f5f8034a511ddc21.zip
Migrate LDAP's install.php to a repair step
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Helper.php12
-rw-r--r--apps/user_ldap/lib/Migration/SetDefaultProvider.php58
2 files changed, 58 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php
index dce67a76c41..67d31516f44 100644
--- a/apps/user_ldap/lib/Helper.php
+++ b/apps/user_ldap/lib/Helper.php
@@ -214,18 +214,6 @@ class Helper {
}
/**
- *
- * Set the LDAPProvider in the config
- *
- */
- public function setLDAPProvider() {
- $current = \OC::$server->getConfig()->getSystemValue('ldapProviderFactory', null);
- if (is_null($current)) {
- \OC::$server->getConfig()->setSystemValue('ldapProviderFactory', LDAPProviderFactory::class);
- }
- }
-
- /**
* sanitizes a DN received from the LDAP server
*
* @param array $dn the DN in question
diff --git a/apps/user_ldap/lib/Migration/SetDefaultProvider.php b/apps/user_ldap/lib/Migration/SetDefaultProvider.php
new file mode 100644
index 00000000000..21998d847b9
--- /dev/null
+++ b/apps/user_ldap/lib/Migration/SetDefaultProvider.php
@@ -0,0 +1,58 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCA\User_LDAP\Migration;
+
+use OCA\User_LDAP\Helper;
+use OCA\User_LDAP\LDAPProviderFactory;
+use OCP\IConfig;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+
+class SetDefaultProvider implements IRepairStep {
+
+ /** @var IConfig */
+ private $config;
+
+ /** @var Helper */
+ private $helper;
+
+ public function __construct(IConfig $config,
+ Helper $helper) {
+ $this->config = $config;
+ $this->helper = $helper;
+ }
+
+ public function getName(): string {
+ return 'Set default LDAP provider';
+ }
+
+ public function run(IOutput $output): void {
+ $current = $this->config->getSystemValue('ldapProviderFactory', null);
+ if ($current === null) {
+ $this->config->setSystemValue('ldapProviderFactory', LDAPProviderFactory::class);
+ }
+ }
+}