summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-08-19 08:31:27 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-08-19 08:31:27 +0200
commitd9172a19070051660e5a94d84e54eaad6854acfd (patch)
tree930ad91f0d9decbb86a43dfd8344259f02309b16 /apps/user_ldap/lib
parent69e72eeb37b6d0084c137e1cffffe8717c2f1de0 (diff)
parent41ad4f46c8e1a02ef811d5a9205041bb7a619144 (diff)
downloadnextcloud-server-d9172a19070051660e5a94d84e54eaad6854acfd.tar.gz
nextcloud-server-d9172a19070051660e5a94d84e54eaad6854acfd.zip
Merge pull request #14401 from owncloud/ux-s2s-ldap
allow login names to be used for s2s with LDAP users
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/helper.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php
index 40874b2ef9f..57b75823a1d 100644
--- a/apps/user_ldap/lib/helper.php
+++ b/apps/user_ldap/lib/helper.php
@@ -27,6 +27,9 @@
namespace OCA\user_ldap\lib;
+use OCA\user_ldap\lib\LDAP;
+use OCA\user_ldap\User_Proxy;
+
class Helper {
/**
@@ -181,4 +184,32 @@ class Helper {
return $domain;
}
+
+ /**
+ * listens to a hook thrown by server2server sharing and replaces the given
+ * login name by a username, if it matches an LDAP user.
+ *
+ * @param array $param
+ * @throws \Exception
+ */
+ public static function loginName2UserName($param) {
+ if(!isset($param['uid'])) {
+ throw new \Exception('key uid is expected to be set in $param');
+ }
+
+ //ain't it ironic?
+ $helper = new Helper();
+
+ $configPrefixes = $helper->getServerConfigurationPrefixes(true);
+ $ldapWrapper = new LDAP();
+ $ocConfig = \OC::$server->getConfig();
+
+ $userBackend = new User_Proxy(
+ $configPrefixes, $ldapWrapper, $ocConfig
+ );
+ $uid = $userBackend->loginName2UserName($param['uid'] );
+ if($uid !== false) {
+ $param['uid'] = $uid;
+ }
+ }
}