My project is to make a module enrollment system for our university. So I contacted the IT people in my university for details to authenticate the students into the system.
@Stephen provided good points. Here is my plain PHP code to authenticate using AD:
use the following code:
$ldap = ldap_connect($host); // e.g. 165.5.54.6 or an URL
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); // Recommended for AD
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($ldap, $username.'@'.$userDomain, $passwrod);
if($bind){
// successful authentication.
}