Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-01-25 23:06:07 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-04-01 19:42:58 +0300
commit3e0566edbf76ce2652b6c792d2a8f8405741444c (patch)
tree4002f02371f6519a66edbc5d0f349106fa3d6322
parent94c8e96a1f07499cc8c1b2ba8e3a7f58d6d0773e (diff)
make ILDAPProviderFactory usable when there is no ldap setupbackport/26402/stable20
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/LDAP/NullLDAPProviderFactory.php36
-rw-r--r--lib/private/Server.php9
-rw-r--r--lib/public/LDAP/ILDAPProviderFactory.php2
5 files changed, 46 insertions, 3 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 0e64da47846..469eda8971c 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1148,6 +1148,7 @@ return array(
'OC\\L10N\\LanguageIterator' => $baseDir . '/lib/private/L10N/LanguageIterator.php',
'OC\\L10N\\LanguageNotFoundException' => $baseDir . '/lib/private/L10N/LanguageNotFoundException.php',
'OC\\L10N\\LazyL10N' => $baseDir . '/lib/private/L10N/LazyL10N.php',
+ 'OC\\LDAP\\NullLDAPProviderFactory' => $baseDir . '/lib/private/LDAP/NullLDAPProviderFactory.php',
'OC\\LargeFileHelper' => $baseDir . '/lib/private/LargeFileHelper.php',
'OC\\Lock\\AbstractLockingProvider' => $baseDir . '/lib/private/Lock/AbstractLockingProvider.php',
'OC\\Lock\\DBLockingProvider' => $baseDir . '/lib/private/Lock/DBLockingProvider.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 13fb59ddfce..acce653597f 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1177,6 +1177,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\L10N\\LanguageIterator' => __DIR__ . '/../../..' . '/lib/private/L10N/LanguageIterator.php',
'OC\\L10N\\LanguageNotFoundException' => __DIR__ . '/../../..' . '/lib/private/L10N/LanguageNotFoundException.php',
'OC\\L10N\\LazyL10N' => __DIR__ . '/../../..' . '/lib/private/L10N/LazyL10N.php',
+ 'OC\\LDAP\\NullLDAPProviderFactory' => __DIR__ . '/../../..' . '/lib/private/LDAP/NullLDAPProviderFactory.php',
'OC\\LargeFileHelper' => __DIR__ . '/../../..' . '/lib/private/LargeFileHelper.php',
'OC\\Lock\\AbstractLockingProvider' => __DIR__ . '/../../..' . '/lib/private/Lock/AbstractLockingProvider.php',
'OC\\Lock\\DBLockingProvider' => __DIR__ . '/../../..' . '/lib/private/Lock/DBLockingProvider.php',
diff --git a/lib/private/LDAP/NullLDAPProviderFactory.php b/lib/private/LDAP/NullLDAPProviderFactory.php
new file mode 100644
index 00000000000..46ac4dd78a3
--- /dev/null
+++ b/lib/private/LDAP/NullLDAPProviderFactory.php
@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl>
+ *
+ * @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 OC\LDAP;
+
+use OCP\IServerContainer;
+use OCP\LDAP\ILDAPProviderFactory;
+
+class NullLDAPProviderFactory implements ILDAPProviderFactory {
+ public function __construct(IServerContainer $serverContainer) {
+ }
+
+ public function getLDAPProvider() {
+ throw new \Exception("No LDAP provider is available");
+ }
+}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 5df928b3dea..dbc11ce0db6 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -197,6 +197,8 @@ use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
+use OCP\LDAP\ILDAPProvider;
+use OCP\LDAP\ILDAPProviderFactory;
use OCP\Lock\ILockingProvider;
use OCP\Log\ILogFactory;
use OCP\Mail\IMailer;
@@ -1002,10 +1004,13 @@ class Server extends ServerContainer implements IServerContainer {
$config = $c->getConfig();
$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
if (is_null($factoryClass)) {
- throw new \Exception('ldapProviderFactory not set');
+ return new NullLDAPProviderFactory($this);
}
/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
- $factory = new $factoryClass($this);
+ return new $factoryClass($this);
+ });
+ $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
+ $factory = $c->get(ILDAPProviderFactory::class);
return $factory->getLDAPProvider();
});
$this->registerService(ILockingProvider::class, function (Server $c) {
diff --git a/lib/public/LDAP/ILDAPProviderFactory.php b/lib/public/LDAP/ILDAPProviderFactory.php
index f005cf07885..9295b5432f8 100644
--- a/lib/public/LDAP/ILDAPProviderFactory.php
+++ b/lib/public/LDAP/ILDAPProviderFactory.php
@@ -44,7 +44,7 @@ interface ILDAPProviderFactory {
* @since 11.0.0
*/
public function __construct(IServerContainer $serverContainer);
-
+
/**
* creates and returns an instance of the ILDAPProvider
*