aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzaczek <pawel@freshmind.pl>2011-10-04 15:37:05 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-11-18 14:05:37 +0100
commit28cd41a2a43ce614199e1b966c1d424efd8b23dd (patch)
treef6fad72904bc59ce3156e5c6552fa2493ba67c7b
parent96b91e5b0b54a9070eec55949d4ff13163b25d8c (diff)
downloadnextcloud-server-28cd41a2a43ce614199e1b966c1d424efd8b23dd.tar.gz
nextcloud-server-28cd41a2a43ce614199e1b966c1d424efd8b23dd.zip
users_ldap - added getUsers() method to fetch all existing users from
LDAP server
-rw-r--r--apps/user_ldap/user_ldap.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 1154efc17b1..4fb8daf3c47 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -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