From c1871f5787cd48eb1e116f7f62bc4d4a50a0a04b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 3 Feb 2016 13:16:55 +0100 Subject: Port of test_ldap_2nddispname to master --- apps/user_ldap/lib/access.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'apps/user_ldap/lib/access.php') diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 82cd342ae2f..16b942084c4 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -521,6 +521,7 @@ class Access extends LDAPUtility implements user\IUserTools { private function ldap2ownCloudNames($ldapObjects, $isUsers) { if($isUsers) { $nameAttribute = $this->connection->ldapUserDisplayName; + $sndAttribute = $this->connection->ldapUserDisplayName2; } else { $nameAttribute = $this->connection->ldapGroupDisplayName; } @@ -542,13 +543,14 @@ class Access extends LDAPUtility implements user\IUserTools { if($isUsers) { //cache the user names so it does not need to be retrieved //again later (e.g. sharing dialogue). - $this->cacheUserExists($ocName); - if(!is_null($nameByLDAP)) { - $this->cacheUserDisplayName($ocName, $nameByLDAP); + if(is_null($nameByLDAP)) { + continue; } + $sndName = isset($ldapObject[$sndAttribute]) + ? $ldapObject[$sndAttribute] : ''; + $this->cacheUserDisplayName($ocName, $nameByLDAP, $sndName); } } - continue; } return $ownCloudNames; } @@ -575,8 +577,11 @@ class Access extends LDAPUtility implements user\IUserTools { * caches the user display name * @param string $ocName the internal ownCloud username * @param string $displayName the display name + * @param string $displayName2 the second display name */ - public function cacheUserDisplayName($ocName, $displayName) { + public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') { + $user = $this->userManager->get($ocName); + $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2); $cacheKeyTrunk = 'getDisplayName'; $this->connection->writeToCache($cacheKeyTrunk.$ocName, $displayName); } @@ -1300,7 +1305,7 @@ class Access extends LDAPUtility implements user\IUserTools { return false; } $result=$testConnection->bind(); - $this->connection->bind(); + $this->ldap->unbind($this->connection->getConnectionResource()); return $result; } -- cgit v1.2.3