PHP LDAP authentication NOT WORKING
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 pos开发者_运维技巧sibly 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";
}
}
I had the same problem recently enough and the solution was to add the domain to the username.
$isAuth = ldap_bind($ldap_conn,$_POST['username'].$ldap_settings['adDomain'], $_POST['password']);
Where $ldap_settings['adDomain']
was "@your_domain"
精彩评论