// Designate a few variables $host = "ldap://ad.domain.controller"; $user = "user@domain.controller"; $pswd = "password"; $ad = ldap_connect($host) or die( "Could not connect!" ); // Set version number ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap protocol"); // Binding to ldap server $bd = ldap_bind($ad, $user, $pswd) or die ("Could not bind"); // Create the DN $dn = "dc=domain,dc=controller"; $dn = "dc=school,dc=cathedral,dc=qld,dc=edu,dc=au"; // Specify only those parameters we're interested in displaying $attrs = array("displayname","mail"); // Create the filter from the search parameters $filter = $_POST['filter']."=".$_POST['keyword']."*"; $search = ldap_search($ad, $dn, $filter, $attrs) or die ("ldap search failed"); $entries = ldap_get_entries($ad, $search); if ($entries["count"] > 0) { for ($i=0; $i<$entries["count"]; $i++) { echo " Name: ".$entries[$i]["displayname"][0]." "; echo "Email: ".$entries[$i]["mail"][0]." "; } } else { echo " No results found! "; } ldap_unbind($ad);