diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-07-01 00:33:39 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-07-01 00:33:39 +0200 |
commit | 0a23d566ba5d756240d2bf812f76f3af8d7aa166 (patch) | |
tree | e91caafe8df14a759e6e4596a009e8458a17845f /apps/user_ldap/lib | |
parent | 16ff6cff54768c15f126e523d195a6993e0e2aea (diff) | |
parent | 5f4db0540af272e4dbb29b550eb6e93904ea26e7 (diff) | |
download | nextcloud-server-0a23d566ba5d756240d2bf812f76f3af8d7aa166.tar.gz nextcloud-server-0a23d566ba5d756240d2bf812f76f3af8d7aa166.zip |
Merge pull request #17255 from owncloud/fix-17119
[LDAP] Filter user groups obtained by memberof
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/access.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index f38d11d4be3..b201220d725 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -347,6 +347,33 @@ class Access extends LDAPUtility implements user\IUserTools { } /** + * accepts an array of group DNs and tests whether they match the user + * filter by doing read operations against the group entries. Returns an + * array of DNs that match the filter. + * + * @param string[] $groupDNs + * @return string[] + */ + public function groupsMatchFilter($groupDNs) { + $validGroupDNs = []; + foreach($groupDNs as $dn) { + $cacheKey = 'groupsMatchFilter-'.$dn; + if($this->connection->isCached($cacheKey)) { + if($this->connection->getFromCache($cacheKey)) { + $validGroupDNs[] = $dn; + } + continue; + } + + $result = $this->readAttribute($dn, 'cn', $this->connection->ldapGroupFilter); + if(is_array($result)) { + $validGroupDNs[] = $dn; + } + } + return $validGroupDNs; + } + + /** * returns the internal ownCloud name for the given LDAP DN of the user, false on DN outside of search DN or failure * @param string $dn the dn of the user object * @param string $ldapName optional, the display name of the object |