LDAP search help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

LDAP search help needed

Post by 9902468 »

I know username (cn=somename) and that o=my_o. How can I get to know in what usergroups the user is in? (ou)

I've tried it like this:

Code: Select all

$ou_rak=ldap_search($ldapConnection,"cn=".$users_username.",o=rollo", "ou=*");
This returns errormsg: Unable to perform search: no such object in...

I'm totally new to LDAP and its consepts. (And context ;), so any help is welcome.)

thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

from ldap_list manual
Example 1. Produce a list of all organizational units of an organization
// $ds is a valid link identifier for a directory server
$basedn = "o=My Company, c=US";
$justthese = array("ou");
$sr=ldap_list($ds, $basedn, "ou=*", $justthese);
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++)
echo $info[$i]["ou"][0] ;
but I'm (still) unfamiliar with LDAP, so no further (context) advices from me ;)
Post Reply