I am trying to implement LDAP authentication into our company web portal. I can successfully connect to the host, but I cannot seem to get a successful bind with my Active Directory credentials. Looking for some help on what could possibly be going wrong. Any help, tips, or advice would be greatly appreciated.
$username = $_POST['username'];
$password = $_POST['password'];
$host = "xxx.xxx.xxx.xxx";
$port = "389";
$connection = ldap_connect($host, $port) or die("Could not connect to LDAP server.");
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($connection) {
$bind = ldap_bind($connection, $username, $password);
if ($bind) {
echo "LDAP bind successful";
}
else {
echo "LDAP bind failed";
}
}