summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-02-03 13:16:55 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-02-03 13:55:39 +0100
commitc1871f5787cd48eb1e116f7f62bc4d4a50a0a04b (patch)
treeaaae91d24fb00638429b1122396a0f3dbb0d129a /apps/user_ldap/lib
parent621f54da514af548bf900f7a1c64af046f53b86d (diff)
downloadnextcloud-server-c1871f5787cd48eb1e116f7f62bc4d4a50a0a04b.tar.gz
nextcloud-server-c1871f5787cd48eb1e116f7f62bc4d4a50a0a04b.zip
Port of test_ldap_2nddispname to master
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/access.php17
-rw-r--r--apps/user_ldap/lib/configuration.php4
-rw-r--r--apps/user_ldap/lib/connection.php1
-rw-r--r--apps/user_ldap/lib/user/manager.php1
-rw-r--r--apps/user_ldap/lib/user/user.php30
5 files changed, 41 insertions, 12 deletions
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;
}
diff --git a/apps/user_ldap/lib/configuration.php b/apps/user_ldap/lib/configuration.php
index 75d244255c6..752f3e81a3e 100644
--- a/apps/user_ldap/lib/configuration.php
+++ b/apps/user_ldap/lib/configuration.php
@@ -47,6 +47,7 @@ class Configuration {
'turnOffCertCheck' => null,
'ldapIgnoreNamingRules' => null,
'ldapUserDisplayName' => null,
+ 'ldapUserDisplayName2' => null,
'ldapUserFilterObjectclass' => null,
'ldapUserFilterGroups' => null,
'ldapUserFilter' => null,
@@ -206,6 +207,7 @@ class Configuration {
case 'ldapAgentPassword':
$readMethod = 'getPwd';
break;
+ case 'ldapUserDisplayName2':
case 'ldapGroupDisplayName':
$readMethod = 'getLcValue';
break;
@@ -416,6 +418,7 @@ class Configuration {
'ldap_groupfilter_objectclass' => '',
'ldap_groupfilter_groups' => '',
'ldap_display_name' => 'displayName',
+ 'ldap_user_display_name_2' => '',
'ldap_group_display_name' => 'cn',
'ldap_tls' => 0,
'ldap_quota_def' => '',
@@ -472,6 +475,7 @@ class Configuration {
'ldap_groupfilter_objectclass' => 'ldapGroupFilterObjectclass',
'ldap_groupfilter_groups' => 'ldapGroupFilterGroups',
'ldap_display_name' => 'ldapUserDisplayName',
+ 'ldap_user_display_name_2' => 'ldapUserDisplayName2',
'ldap_group_display_name' => 'ldapGroupDisplayName',
'ldap_tls' => 'ldapTLS',
'ldap_quota_def' => 'ldapQuotaDefault',
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index addd7d0b51d..b1ed23f95fe 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -37,6 +37,7 @@ use OC\ServerNotAvailableException;
*
* @property string ldapUserFilter
* @property string ldapUserDisplayName
+ * @property string ldapUserDisplayName2
* @property boolean hasPagedResultSupport
* @property string[] ldapBaseUsers
* @property int|string ldapPagingSize holds an integer
diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php
index cfa333b06d4..d76142c79ac 100644
--- a/apps/user_ldap/lib/user/manager.php
+++ b/apps/user_ldap/lib/user/manager.php
@@ -147,6 +147,7 @@ class Manager {
$this->access->getConnection()->ldapQuotaAttribute,
$this->access->getConnection()->ldapEmailAttribute,
$this->access->getConnection()->ldapUserDisplayName,
+ $this->access->getConnection()->ldapUserDisplayName2,
);
foreach($possible as $attr) {
if(!is_null($attr)) {
diff --git a/apps/user_ldap/lib/user/user.php b/apps/user_ldap/lib/user/user.php
index 13f88aa6507..3bc790a6c10 100644
--- a/apps/user_ldap/lib/user/user.php
+++ b/apps/user_ldap/lib/user/user.php
@@ -168,13 +168,22 @@ class User {
unset($attr);
//displayName
+ $displayName = $displayName2 = '';
$attr = strtolower($this->connection->ldapUserDisplayName);
if(isset($ldapEntry[$attr])) {
$displayName = $ldapEntry[$attr][0];
- if(!empty($displayName)) {
- $this->storeDisplayName($displayName);
- $this->access->cacheUserDisplayName($this->getUsername(), $displayName);
- }
+ }
+ $attr = strtolower($this->connection->ldapUserDisplayName2);
+ if(isset($ldapEntry[$attr])) {
+ $displayName2 = $ldapEntry[$attr][0];
+ }
+ if(!empty($displayName)) {
+ $this->composeAndStoreDisplayName($displayName);
+ $this->access->cacheUserDisplayName(
+ $this->getUsername(),
+ $displayName,
+ $displayName2
+ );
}
unset($attr);
@@ -350,6 +359,7 @@ class User {
/**
* Stores a key-value pair in relation to this user
+ *
* @param string $key
* @param string $value
*/
@@ -358,11 +368,19 @@ class User {
}
/**
- * Stores the display name in the databae
+ * Composes the display name and stores it in the database. The final
+ * display name is returned.
+ *
* @param string $displayName
+ * @param string $displayName2
+ * @returns string the effective display name
*/
- public function storeDisplayName($displayName) {
+ public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
+ if(!empty($displayName2)) {
+ $displayName .= ' (' . $displayName2 . ')';
+ }
$this->store('displayName', $displayName);
+ return $displayName;
}
/**