summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/user_ldap/appinfo/app.php26
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 9e72e388e67..69860ba1432 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -23,11 +23,27 @@
OCP\App::registerAdmin('user_ldap', 'settings');
-$connector = new OCA\user_ldap\lib\Connection('', 'user_ldap');
-$userBackend = new OCA\user_ldap\USER_LDAP();
-$userBackend->setConnector($connector);
-$groupBackend = new OCA\user_ldap\GROUP_LDAP();
-$groupBackend->setConnector($connector);
+$query = \OCP\DB::prepare('
+ SELECT DISTINCT `configkey`
+ FROM `*PREFIX*appconfig`
+ WHERE `configkey` LIKE ?
+');
+$serverConnections = $query->execute(array('%ldap_login_filter'))->fetchAll();
+if(count($serverConnections) == 1) {
+ $prefix = substr($serverConnections[0]['configkey'], 0, strlen($serverConnections[0]['configkey'])- strlen('ldap_login_filter'));
+ $connector = new OCA\user_ldap\lib\Connection($prefix);
+ $userBackend = new OCA\user_ldap\USER_LDAP();
+ $userBackend->setConnector($connector);
+ $groupBackend = new OCA\user_ldap\GROUP_LDAP();
+ $groupBackend->setConnector($connector);
+} else {
+ $prefixes = array();
+ foreach($serverConnections as $serverConnection) {
+ $prefixes[] = substr($serverConnection['configkey'], 0, strlen($serverConnection['configkey'])- strlen('ldap_login_filter'));
+ }
+ $userBackend = new OCA\user_ldap\User_Proxy($prefixes);
+ $groupBackend = new OCA\user_ldap\Group_Proxy($prefixes);
+}
// register user backend
OC_User::useBackend($userBackend);