This is an example of how to query an LDAP server, and print all entries out.
<?php
$ldapServer = '127.0.0.1';
$ldapBase = 'DC=anlx,DC=net';
$ldapConn = ldap_connect($ldapServer);
if (!$ldapConn)
{
die('Cannot Connect to LDAP server');
}
$ldapBind = ldap_bind($ldapConn);
if (!$ldapBind)
{
die('Cannot Bind to LDAP server');
}
ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);
$ldapSearch = ldap_search($ldapConn, $ldapBase, "(cn=*)");
$ldapResults = ldap_get_entries($ldapConn, $ldapSearch);
for ($item = 0; $item < $ldapResults['count']; $item++)
{
for ($attribute = 0; $attribute < $ldapResults[$item]['count']; $attribute++)
{
$data = $ldapResults[$item][$attribute];
echo $data.": ".$ldapResults[$item][$data][0]."<br>";
}
echo '<hr />';
}
?>