]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: central function for user and group list retrieval (will replace retrieveList...
authorArthur Schiwon <blizzz@owncloud.com>
Thu, 3 May 2012 21:38:55 +0000 (23:38 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Fri, 4 May 2012 11:26:07 +0000 (13:26 +0200)
apps/user_ldap/lib_ldap.php

index 2571ff8d76f513fb677ef6ef4a16fa42caa5f50e..52cc8616e2b1bbbbea447bb543d3e9da956cb7a4 100755 (executable)
@@ -371,6 +371,27 @@ class OC_LDAP {
                return !OCP\DB::isError($res);
        }
 
+       static public function fetchListOfUsers($filter, $attr) {
+               return self::fetchList(OC_LDAP::searchUsers($filter, $attr), (count($attr) > 1));
+       }
+
+       static public function fetchListOfGroups($filter, $attr) {
+               return self::fetchList(OC_LDAP::searchGroups($filter, $attr), (count($attr) > 1));
+       }
+
+       static private function fetchList($list, $manyAttributes) {
+               if(is_array($list)) {
+                       if($manyAttributes) {
+                               return $list;
+                       } else {
+                               return array_unique($list, SORT_LOCALE_STRING);
+                       }
+               }
+
+               //error cause actually, maybe throw an exception in future.
+               return array();
+       }
+
        /**
         * @brief reads a given attribute for an LDAP record identified by a DN
         * @param $dn the record in question