Hello, I am running PHP on IIS5.0. I want users that come on the intranet to be authenticated through the Active Directory. In other words, for example if user that comes to the page belongs to a certain group in Active Directory, he/she will see one page, but if user belongs to a different group in Active Directory he/she will see a different page. I've read on the Internet that it can be done with LDAP, but I wasn't able to find any detailed information on how it can actually be done. I tried to do it myself using LDAP functions described on the php.net, but I've hit the wall. It looks like I am able to connect to the LDAP server and bind it, but I can't seem to do any search on it. Below is the code that I used. Can anybody help?
<?php // specify the LDAP server to connect to $conn = ldap_connect("192.XXX.XXX.XXX") or die("Could not connect to server"); // bind to the LDAP server specified above $r = ldap_bind($conn) or die("Could not bind to server"); // verify binding if ($r) { echo "LDAP bind successful..."; } else { echo "LDAP bind failed..."; } // start searching // specify both the start location and the search criteria // in this case, start at the top and return all entries $base_dn = "DC=my_domain,DC=com"; $filter = "(cn=*)"; $result = ldap_search($conn, $base_dn, $filter) or die ("Error in search query"); // get entry data as array $info = ldap_get_entries($conn, $result); // iterate over array and print data for each entry for ($i=0; $i<$info["count"]; $i++) { echo "dn is: ". $info[$i]["dn"] ."<br>"; echo "first cn is: ". $info[$i]["cn"][0] ."<br>"; echo "first email address is: ". $info[$i]["mail"][0] ."<p>"; } // print number of entries found echo "Number of entries found: " . ldap_count_entries($conn, $result) . "<p>"; // all done? clean up ldap_close($conn); ?> -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php