<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection

$server = '472lang1.lang.uc.edu';
$name = $_POST['username'];
$searchstring="(cn=$name)";
$ds=ldap_connect($server);  // must be a valid LDAP server!

if ($ds) {
	$r=ldap_search($ds,"ou=Users,o=ucl", $searchstring);
		if($r) echo "ldap_search success<br>";
	$entry = ldap_first_entry($ds, $r);
	$attrs = ldap_get_attributes($ds, $entry);
	echo $attrs["count"] . " attributes held for this entry:<p>";
	
	for ($i=0; $i < $attrs["count"]; $i++) {
	    echo $attrs[$i] . "<br />";
			
	}
	
}
else {
	echo "<h4>Unable to connect to LDAP server</h4>";
	}
?>
