]> source.dussan.org Git - nextcloud-server.git/commitdiff
users_ldap - added getUsers() method to fetch all existing users from
authorkrzaczek <pawel@freshmind.pl>
Tue, 4 Oct 2011 13:37:05 +0000 (15:37 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Fri, 18 Nov 2011 13:05:37 +0000 (14:05 +0100)
LDAP server

apps/user_ldap/user_ldap.php

index 1154efc17b194e0810109fd22502e79c56e13295..4fb8daf3c4789667b3ff01c0054353eed0560dac 100644 (file)
@@ -65,7 +65,7 @@ class OC_USER_LDAP extends OC_User_Backend {
                        $this->ds = ldap_connect( $this->ldap_host, $this->ldap_port );
                           if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
                                 if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0))
-                                         ldap_start_tls($this->ds);
+                                         @ldap_start_tls($this->ds);
                }
 
                // login
@@ -117,7 +117,36 @@ class OC_USER_LDAP extends OC_User_Backend {
                $dn = $this->getDn($uid);
                return !empty($dn);
        }
+       
+       public function getUsers()
+       {
+               if(!$this->configured)
+               return false;
+       
+               // connect to server
+               $ds = $this->getDs();
+               if( !$ds )
+                       return false;
+       
+               // get users
+               $filter = "objectClass=person";
+               $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
+               $entries = ldap_get_entries( $this->getDs(), $sr );
+       
+               if( $entries["count"] == 0 )
+                       return false;
+               else {
+                       $users = array();
+                       foreach($entries as $row) {
+                               if(isset($row['uid'])) {
+                                       $users[] = $row['uid'][0];
+                               }
+                       }
+               }
+       
+               return $users;
+       }
 
 }
 
-?>
+?>
\ No newline at end of file