$ds=ldap_connect("ldapserver");
if ($ds) {
$r=ldap_bind($ds); #bind to directory
$sr=ldap_search($ds,"dc=domain,dc=net", "uid=user"); #search for user
print "Number of entires returned is " .ldap_count_entries($ds,$sr)."<p>";
$info = ldap_get_entries($ds, $sr); #get the result
print "Data for ".$info["count"]." items returned:<p>";
for ($i=0; $i<$info["count"]; $i++) { #loop though ldap search result
print "dn: " . $info[$i]["dn"] . "<br>"; #print dn
for ($ii=0; $ii<$info[$i]["count"]; $ii++) { #loop though attributes in this dn
print " " . $info[$i][$ii] . ": "; #print attribute name
$attrib = $info[$i][$ii]; #set attribute
eval("print \$info[\$i][\"$attrib\"][0];"); #print attribute value
print "<br>";
}
print "<br>";
}
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}