
February 4th, 2008, 12:12 PM
|
|
Registered User
|
|
Join Date: Feb 2008
Location: Belgium
Posts: 2
Time spent in forums: 39 m 7 sec
Reputation Power: 0
|
|
|
PHP Get group list from user
hello,
first of all, I am a complete noob when it comes to LDAP
I'm trying to use php to get the group list from a user. I've searched on the internet, this forums but I can't find a solution, and I don't have any idea on how to start with this.
The username i have is in the form of DOMAIN\username.
Another problem is that when I try the sample code on php.net I can't get it to show the data.
The domain is on a win2003 server. The Forest functional level is Windows 2000, and the Domain functional level Windows Server 2003.
I'm using php5 on an iis 6 server, and the ldap extension is enabled.
The php sample file:
PHP Code:
<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("srvr-isa"); // must be a valid LDAP server!
echo "connect result is " . $ds . "<br />";
if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds); // this is an "anonymous" bind, typically
// read-only access
echo "Bind result is " . $r . "<br />";
echo "Searching for (sn=*) ...";
// Search surname entry
$sr=ldap_search($ds, "o=Hoefman, c=BE", "sn=*");
echo "Search result is " . $sr . "<br />";
echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "<br />";
echo "Getting entries ...<p>";
$info = ldap_get_entries($ds, $sr);
echo "Data for " . $info["count"] . " items returned:<p>";
for ($i=0; $i<$info["count"]; $i++) {
echo "dn is: " . $info[$i]["dn"] . "<br />";
echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";
}
echo "Closing connection";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>
And this is the output:
Code:
LDAP query test
Connecting ...connect result is Resource id #1
Binding ...Bind result is 1
Searching for (sn=*) ...Search result is
Number of entires returned is
Getting entries ...
Data for items returned:
Closing connection
thx,
Stijn
Last edited by Kiekeboe100 : February 4th, 2008 at 12:23 PM.
Reason: added php5, iis6, ...
|