Reputation: 23634
How can i get all the users from the LDAP using PHP.
function getUsers() {
$process = new process();
//ldap->s_Host('domain.com');
//$ldap->s_Domain('domain.com');
$process->s_Host('domain.com');
$process->s_Domain('domain.com');
$process->s_LdapSecure(false);
if($process->LdapConn()){
if($process->LdapBind()){
}
}
}
Upvotes: 1
Views: 1047
Reputation: 4100
Watch out for limits... AD defaults to 1000 objects returned, so you will have a problem, if there are more objects than that in the AD domain. eDirectory lets you configure the number number, but defaults to unlimited. OpenLDAP, dunno.
You probably want to specify an attribute to retrieve, even if only cn or uid, else the default is all attributes, which would be rank foolishness.
You may wish to scope it to an objectClass (say user, inetorgperson or the like, depending on your backend server).
Upvotes: 0
Reputation: 83622
That's a question like "How do I land an airplane?"... :-)
You need to provide a lot more details on what you're going to do, what you've already done and so on...
First of all it depends on what type of LDAP server your talking of (OpenLDAP or Active Directory for example) and what LDAP schema the server uses (Active Directory has a clear standard on this but especially OpenLDAP can store users in an arbitrary schema). If you've figured out these details you can famliarize yourself with ext/ldap, which is the LDAP extension library for PHP, or some higher abstraction such as PEAR's Net_LDAP2. If you have a basic understand on how LDAP communication works and if you encounter problems in executing the whole thing in PHP with ext/ldap you should edit your question to be more specific.
In general a LDAP communication session involves:
ldap_connect()
ldap_bind()
ldap_unbind()
The carry out operations on the server (in your case: retrieve all user accounts) now strongly depends on the server and/or schema you're using.
Upvotes: 7