diff options
Diffstat (limited to 'apps/user_ldap/lib/helper.php')
-rw-r--r-- | apps/user_ldap/lib/helper.php | 31 |
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; + } + } } |