summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-01-29 14:05:54 -0800
committerLukas Reschke <lukas@statuscode.ch>2013-01-29 14:05:54 -0800
commit250c565d2be9ebd7033c43c3362a44c58964c79b (patch)
treef8354bf6b5d6a8a37b46d4685f09342d41dd2695 /apps/user_ldap
parent472491955ae7e8172b113bd564ec242cc8bc4577 (diff)
parent665979819766bd23cddc18a3e1666f303ac25932 (diff)
downloadnextcloud-server-250c565d2be9ebd7033c43c3362a44c58964c79b.tar.gz
nextcloud-server-250c565d2be9ebd7033c43c3362a44c58964c79b.zip
Merge pull request #1360 from owncloud/display_name
introduction of display names
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/user_ldap.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 6591d1d5fee..4928ad2e27f 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -208,6 +208,50 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
return false;
}
+ /**
+ * @brief get display name of the user
+ * @param $uid user ID of the user
+ * @return display name
+ */
+ public function getDisplayName($uid) {
+ $cacheKey = 'getDisplayName'.$uid;
+ if(!is_null($displayName = $this->connection->getFromCache($cacheKey))) {
+ return $displayName;
+ }
+
+ $displayName = $this->readAttribute(
+ $this->username2dn($uid),
+ $this->connection->ldapUserDisplayName);
+
+ if($displayName && (count($displayName) > 0)) {
+ $this->connection->writeToCache($cacheKey, $displayName);
+ return $displayName[0];
+ }
+
+ return null;
+ }
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset;
+ if(!is_null($displayNames = $this->connection->getFromCache($cacheKey))) {
+ return $displayNames;
+ }
+
+ $displayNames = array();
+ $users = $this->getUsers($search, $limit, $offset);
+ foreach ($users as $user) {
+ $displayNames[$user] = $this->getDisplayName($user);
+ }
+ $this->connection->writeToCache($cacheKey, $displayNames);
+ return $displayNames;
+ }
+
/**
* @brief Check if backend implements actions
* @param $actions bitwise-or'ed actions