Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-05-23 17:58:58 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-05-27 13:03:05 +0300
commitc6c8a41d2f34a05dbb8b24b280c767b022a3c338 (patch)
tree45852452a236211e8126fce4557baa4aa435f0d2 /apps/user_ldap/lib
parent96e892770d0b37fab66f8b92c10866fadccf98c5 (diff)
group display name support (service level + ldap)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Access.php7
-rw-r--r--apps/user_ldap/lib/Connection.php1
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php28
-rw-r--r--apps/user_ldap/lib/Group_Proxy.php7
4 files changed, 41 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 1044938446e..6a074bbed2e 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -712,6 +712,8 @@ class Access extends LDAPUtility {
$sndName = isset($ldapObject[$sndAttribute][0])
? $ldapObject[$sndAttribute][0] : '';
$this->cacheUserDisplayName($ncName, $nameByLDAP, $sndName);
+ } else if($nameByLDAP !== null) {
+ $this->cacheGroupDisplayName($ncName, $nameByLDAP);
}
}
}
@@ -765,6 +767,11 @@ class Access extends LDAPUtility {
$this->connection->writeToCache($cacheKeyTrunk.$ocName, $displayName);
}
+ public function cacheGroupDisplayName(string $ncName, string $displayName): void {
+ $cacheKey = 'group_getDisplayName' . $ncName;
+ $this->connection->writeToCache($cacheKey, $displayName);
+ }
+
/**
* creates a unique name for internal Nextcloud use for users. Don't call it directly.
* @param string $name the display name of the object
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 4335f8e4397..35770f082fa 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -65,6 +65,7 @@ use OCP\ILogger;
* @property bool|string ldapNestedGroups
* @property string[] ldapBaseGroups
* @property string ldapGroupFilter
+ * @property string ldapGroupDisplayName
*/
class Connection extends LDAPUtility {
private $ldapConnectionRes = null;
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index cd4bd18cb44..ae2434056b1 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -42,10 +42,11 @@
namespace OCA\User_LDAP;
use OC\Cache\CappedMemoryCache;
+use OCP\Group\Backend\IGetDisplayNameBackend;
use OCP\GroupInterface;
use OCP\ILogger;
-class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP {
+class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP, IGetDisplayNameBackend {
protected $enabled = false;
/**
@@ -1221,4 +1222,29 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
return $connection->getConnectionResource();
}
+ /**
+ * @throws \OC\ServerNotAvailableException
+ */
+ public function getDisplayName(string $gid): string {
+ if ($this->groupPluginManager instanceof IGetDisplayNameBackend) {
+ return $this->groupPluginManager->getDisplayName($gid);
+ }
+
+ $cacheKey = 'group_getDisplayName' . $gid;
+ if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) {
+ return $displayName;
+ }
+
+ $displayName = $this->access->readAttribute(
+ $this->access->groupname2dn($gid),
+ $this->access->connection->ldapGroupDisplayName);
+
+ if ($displayName && (count($displayName) > 0)) {
+ $displayName = $displayName[0];
+ $this->access->connection->writeToCache($cacheKey, $displayName);
+ return $displayName;
+ }
+
+ return '';
+ }
}
diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php
index 9fccb64cd46..c0599ad4870 100644
--- a/apps/user_ldap/lib/Group_Proxy.php
+++ b/apps/user_ldap/lib/Group_Proxy.php
@@ -27,7 +27,9 @@
namespace OCA\User_LDAP;
-class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP {
+use OCP\Group\Backend\IGetDisplayNameBackend;
+
+class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGetDisplayNameBackend {
private $backends = array();
private $refBackend = null;
@@ -272,4 +274,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP {
return $this->handleRequest($gid, 'getNewLDAPConnection', array($gid));
}
+ public function getDisplayName(string $gid): string {
+ return $this->handleRequest($gid, 'getDisplayName', [$gid]);
+ }
}