Skip to content
Snippets Groups Projects
Commit 28cd41a2 authored by krzaczek's avatar krzaczek Committed by Robin Appelman
Browse files

users_ldap - added getUsers() method to fetch all existing users from

LDAP server
parent 96b91e5b
Branches
No related tags found
No related merge requests found
......@@ -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
......@@ -118,6 +118,35 @@ class OC_USER_LDAP extends OC_User_Backend {
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment