From 8a6fa65ed6dcd7b81891e9a06b771c1c464ebcb9 Mon Sep 17 00:00:00 2001
From: Arthur Schiwon <blizzz@owncloud.com>
Date: Sun, 15 Apr 2012 14:20:33 +0200
Subject: [PATCH] group LDAP: implemented getUsersInGroup()

---
 apps/user_ldap/group_ldap.php | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php
index 92bc59c0de..19a488b843 100644
--- a/apps/user_ldap/group_ldap.php
+++ b/apps/user_ldap/group_ldap.php
@@ -69,14 +69,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
 			$this->ldapGroupFilter,
 			LDAP_GROUP_MEMBER_ASSOC_ATTR.'='.$uid
 		));
-		$groups = OC_LDAP::search($filter, $this->ldapGroupDisplayName);
-
-		if(is_array($groups)) {
-			return $groups;
-		}
 
-		//error cause actually, maybe throw an exception in future.
-		return array();
+		return $this->retrieveList($filter, $this->ldapGroupDisplayName);
 	}
 
 	/**
@@ -84,7 +78,12 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
 	 * @returns array with user ids
 	 */
 	public function getUsersInGroup($gid) {
-		return array();
+		$filter = OC_LDAP::combineFilterWithAnd(array(
+			$this->ldapGroupFilter,
+			$this->ldapGroupDisplayName.'='.$gid
+		));
+
+		return $this->retrieveList($filter, OC_LDAP::ldapUserDisplayName);
 	}
 
 	/**
@@ -103,4 +102,15 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
 		}
 	}
 
+	private function retrieveList($filter, $attr) {
+		$list = OC_LDAP::search($filter, $attr);
+
+		if(is_array($list)) {
+			return array_unique($list, SORT_LOCALE_STRING);
+		}
+
+		//error cause actually, maybe throw an exception in future.
+		return array();
+	}
+
 }
\ No newline at end of file
-- 
GitLab