summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/group_ldap.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-04-23 13:04:58 +0200
committerArthur Schiwon <blizzz@owncloud.com>2012-04-23 13:04:58 +0200
commit912c87eedaa3ea909d5721d8066fa4455529aa1b (patch)
tree020c139440b1f3831a4d4b1a907cfd679904938a /apps/user_ldap/group_ldap.php
parent6ee7dc5f590e26f54d2a986a72bb328ed0b0db8f (diff)
downloadnextcloud-server-912c87eedaa3ea909d5721d8066fa4455529aa1b.tar.gz
nextcloud-server-912c87eedaa3ea909d5721d8066fa4455529aa1b.zip
LDAP: optimize LDAP requests for users and groups. Settings are still to do, though.
Diffstat (limited to 'apps/user_ldap/group_ldap.php')
-rw-r--r--apps/user_ldap/group_ldap.php27
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php
index b1619e06530..fe0789cdeb7 100644
--- a/apps/user_ldap/group_ldap.php
+++ b/apps/user_ldap/group_ldap.php
@@ -47,14 +47,12 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
LDAP_GROUP_MEMBER_ASSOC_ATTR.'='.$uid,
$this->ldapGroupDisplayName.'='.$gid
));
- $groups = OC_LDAP::search($filter, $this->ldapGroupDisplayName);
+ $groups = $this->retrieveList($filter, $this->ldapGroupDisplayName);
- if(count($groups) == 1) {
+ if(count($groups) > 0) {
return true;
- } else if(count($groups) < 1) {
- return false;
} else {
- throw new Exception('Too many groups of the same name!? – this exception should never been thrown :)');
+ return false;
}
}
@@ -85,7 +83,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
$this->ldapGroupDisplayName.'='.$gid
));
- return $this->retrieveList($filter, $this->ldapGroupMemberAttr);
+ return $this->retrieveList($filter, $this->ldapGroupMemberAttr, false);
}
/**
@@ -95,13 +93,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
* Returns a list with all groups
*/
public function getGroups() {
- $groups = OC_LDAP::search($this->ldapGroupFilter, $this->ldapGroupDisplayName);
-
- if(count($groups) == 0 )
- return array();
- else {
- return array_unique($groups, SORT_LOCALE_STRING);
- }
+ return $this->retrieveList($this->ldapGroupFilter, $this->ldapGroupDisplayName);
}
/**
@@ -113,8 +105,13 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
return in_array($gid, $this->getGroups());
}
- private function retrieveList($filter, $attr) {
- $list = OC_LDAP::search($filter, $attr);
+ private function retrieveList($filter, $attr, $searchForGroups = true) {
+ if($searchForGroups) {
+ $list = OC_LDAP::searchGroups($filter, $attr);
+ } else {
+ $list = OC_LDAP::searchUsers($filter, $attr);
+ }
+
if(is_array($list)) {
return array_unique($list, SORT_LOCALE_STRING);