/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // basic sequence with LDAP is connect, bind, search, interpret search // result, close connection // using ldap bind $ldaprdn = 'userid'; // ldap rdn or dn $ldappass = 'password'; // associated password echo "<h3>LDAP query test</h3>"; echo "Connecting ..."; // connect to ldap server // Set some ldap options for talking to echo "connect result is " . $ldapconn . "<br />"; if ($ldapconn) { echo "Binding ..."; // read-only access echo "Bind result is " . $r . "<br />"; echo "Searching for (sn=S*) ..."; // Search surname entry echo "Search result is " . $sr . "<br />"; echo "Getting entries ...<p>"; echo "Data for " . $info["count"] . " items returned:<p>"; /*for ($i=0; $i<$info["count"]; $i++) { //echo "dn is: " . $info[$i]["dn"] . "<br />"; echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />"; echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />"; }*/ echo "Closing connection"; } else { echo "<h4>Unable to connect to LDAP server</h4>"; } ?>