[Pkg-owncloud-commits] [owncloud] 55/70: backport of #9848
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:40:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v6.0.5RC1
in repository owncloud.
commit 2a34f530b27f7c85ce612e4cd9cf04e9edf9d83a
Author: Jean-Louis Dupond <jean-louis at dupond.be>
Date: Thu Jul 24 14:18:41 2014 +0200
backport of #9848
Fix memberOf detection. Fixes: #9835
Conflicts:
apps/user_ldap/lib/wizard.php
Fix remarks in #9848
Conflicts:
apps/user_ldap/lib/wizard.php
Fix initializing in #9848
do not change var names here
---
apps/user_ldap/lib/wizard.php | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index 27181f2..c2e9ed5 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -253,10 +253,10 @@ class Wizard extends LDAPUtility {
throw new \Exception('Could not connect to LDAP');
}
- $this->fetchGroups($dbkey, $confkey);
+ $groups = $this->fetchGroups($dbkey, $confkey);
if($testMemberOf) {
- $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf();
+ $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf($groups);
$this->result->markChange();
if(!$this->configuration->hasMemberOfFilterSupport) {
throw new \Exception('memberOf is not supported by the server');
@@ -270,6 +270,7 @@ class Wizard extends LDAPUtility {
* fetches all groups from LDAP
* @param string $dbKey
* @param string $confKey
+ * @return array $groupEntries
*/
public function fetchGroups($dbKey, $confKey) {
$obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames');
@@ -285,19 +286,22 @@ class Wizard extends LDAPUtility {
$filter = $ldapAccess->combineFilterWithOr($filterParts);
$filter = $ldapAccess->combineFilterWithAnd(array($filter, 'cn=*'));
+ $groupNames = array();
+ $groupEntries = array();
$limit = 400;
$offset = 0;
do {
- $result = $ldapAccess->searchGroups($filter, array('cn'), $limit, $offset);
+ $result = $ldapAccess->searchGroups($filter, array('cn','dn'), $limit, $offset);
foreach($result as $item) {
- $groups[] = $item[0];
+ $groupNames[] = $item['cn'];
+ $groupEntries[] = $item;
}
$offset += $limit;
- } while (count($groups) > 0 && count($groups) % $limit === 0);
+ } while (count($groupNames) > 0 && count($groupNames) % $limit === 0);
- if(count($groups) > 0) {
- natsort($groups);
- $this->result->addOptions($dbKey, array_values($groups));
+ if(count($groupNames) > 0) {
+ natsort($groupNames);
+ $this->result->addOptions($dbKey, array_values($groupNames));
} else {
throw new \Exception(self::$l->t('Could not find the desired feature'));
}
@@ -307,6 +311,7 @@ class Wizard extends LDAPUtility {
//something is already configured? pre-select it.
$this->result->addChange($dbKey, $setFeatures);
}
+ return $groupEntries;
}
public function determineGroupMemberAssoc() {
@@ -622,9 +627,11 @@ class Wizard extends LDAPUtility {
* @brief Checks whether the server supports memberOf in LDAP Filter.
* Requires that groups are determined, thus internally called from within
* determineGroups()
- * @return bool, true if it does, false otherwise
+ * @param array $groups
+ * @return bool true if it does, false otherwise
+ * @throws \Exception
*/
- private function testMemberOf() {
+ private function testMemberOf($groups) {
$cr = $this->getConnection();
if(!$cr) {
throw new \Exception('Could not connect to LDAP');
@@ -637,12 +644,12 @@ class Wizard extends LDAPUtility {
$filterPrefix = '(&(objectclass=*)(memberOf=';
$filterSuffix = '))';
- foreach($this->resultCache as $dn => $properties) {
- if(!isset($properties['cn'])) {
+ foreach($groups as $groupProperties) {
+ if(!isset($groupProperties['cn'])) {
//assuming only groups have their cn cached :)
continue;
}
- $filter = strtolower($filterPrefix . $dn . $filterSuffix);
+ $filter = strtolower($filterPrefix . $groupProperties['dn'] . $filterSuffix);
$rr = $this->ldap->search($cr, $base, $filter, array('dn'));
if(!$this->ldap->isResource($rr)) {
continue;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list