Well I have it compiled and my phpinfo says it is enabled. I tried this code without success!
code:
<?php
$ldap_server = "ldap://server.domain.local";
$auth_user = "loserboy@domain.local";
$auth_pass = "password";
// Set the base dn to search the entire directory.
$base_dn = "CN=Users, DC=domain, DC=local";
// Show only user persons
$filter = "(&(objectClass=user)(objectCategory=person)(cn=*))";
// Enable to show only users
// $filter = "(&(objectClass=user)(cn=$*))";
// Enable to show everything
// $filter = "(cn=*)";
// connect to server
if (!($connect=@ldap_connect($ldap_server))) {
die("Could not connect to ldap server");
}
// bind to server
if (!($bind=@ldap_bind($connect, $auth_user, $auth_pass))) {
die("Unable to bind to server");
}
//if (!($bind=@ldap_bind($connect))) {
// die("Unable to bind to server");
//}
// search active directory
if (!($search=@ldap_search($connect, $base_dn, $filter))) {
die("Unable to search ldap server");
}
$number_returned = ldap_count_entries($connect,$search);
$info = ldap_get_entries($connect, $search);
echo "The number of entries returned is ". $number_returned."<p>";
for ($i=0; $i<$info["count"]; $i++) {
echo "Name is: ". $info[$i]["name"][0]."<br>";
echo "Display name is: ". $info[$i]["displayname"][0]."<br>";
echo "Email is: ". $info[$i]["mail"][0]."<br>";
echo "Telephone number is: ". $info[$i]["telephonenumber"][0]."<p>";
}
?>
Now I keep seeing something about Windows 2003 LDAP with this variable:
ldap_set_option( $ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3 ) or
die ("Could not set LDAP Protocol version");
I am not sure where to place it and on the original code I keep getting "Could not connect to ldap server"