summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/appinfo/app.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-01-16 14:59:41 +0100
committerArthur Schiwon <blizzz@owncloud.com>2013-01-16 14:59:41 +0100
commit6063ce9c8d3f32a7c9d53a0aa77d2cbfa0798f7b (patch)
treedca3ff97a134c11aed4387b945381439d90e5499 /apps/user_ldap/appinfo/app.php
parent4699f36e4406a50e3b44a2b69b3ecc37a93c321c (diff)
downloadnextcloud-server-6063ce9c8d3f32a7c9d53a0aa77d2cbfa0798f7b.tar.gz
nextcloud-server-6063ce9c8d3f32a7c9d53a0aa77d2cbfa0798f7b.zip
LDAP: enable support for multiple LDAP/AD servers
Diffstat (limited to 'apps/user_ldap/appinfo/app.php')
-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);