diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-06 13:27:01 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-06 13:27:01 +0100 |
commit | 69a4cd2898d8b65257ccd1e526a4c3baad386a31 (patch) | |
tree | 0c3d61efde1dc0e090b13f68cc2b2a0ef3f0f15d /apps/user_ldap/user_ldap.php | |
parent | 5832178f591f1efca48e06c78dfb7a0405a7cce4 (diff) | |
parent | c1871f5787cd48eb1e116f7f62bc4d4a50a0a04b (diff) | |
download | nextcloud-server-69a4cd2898d8b65257ccd1e526a4c3baad386a31.tar.gz nextcloud-server-69a4cd2898d8b65257ccd1e526a4c3baad386a31.zip |
Merge pull request #22102 from owncloud/ldap_2nddispname-master
[LDAP] add second field for additional/optional display name attribute
Diffstat (limited to 'apps/user_ldap/user_ldap.php')
-rw-r--r-- | apps/user_ldap/user_ldap.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 65a4bbdda77..865b7e61892 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -176,6 +176,11 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn $this->access->connection->ldapUserDisplayName . '=*', $this->access->getFilterPartForUserSearch($search) )); + $attrs = array($this->access->connection->ldapUserDisplayName, 'dn'); + $additionalAttribute = $this->access->connection->ldapUserDisplayName2; + if(!empty($additionalAttribute)) { + $attrs[] = $additionalAttribute; + } \OCP\Util::writeLog('user_ldap', 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, @@ -350,13 +355,30 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn return $displayName; } + //Check whether the display name is configured to have a 2nd feature + $additionalAttribute = $this->access->connection->ldapUserDisplayName2; + $displayName2 = ''; + if(!empty($additionalAttribute)) { + $displayName2 = $this->access->readAttribute( + $this->access->username2dn($uid), + $additionalAttribute); + } + $displayName = $this->access->readAttribute( $this->access->username2dn($uid), $this->access->connection->ldapUserDisplayName); if($displayName && (count($displayName) > 0)) { - $this->access->connection->writeToCache($cacheKey, $displayName[0]); - return $displayName[0]; + $displayName = $displayName[0]; + + if(is_array($displayName2) && (count($displayName2) > 0)) { + $displayName2 = $displayName2[0]; + } + + $user = $this->access->userManager->get($uid); + $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2); + $this->access->connection->writeToCache($cacheKey, $displayName); + return $displayName; } return null; |