PHP LDAP身份验证无效

Bre*_*ett 2 php ldap

我正在尝试将LDAP身份验证实施到我们公司的Web门户中.我可以成功连接到主机,但似乎无法与我的Active Directory凭据成功绑定.寻找可能出错的一些帮助.任何帮助,提示或建议将不胜感激.

$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";
    }
}
Run Code Online (Sandbox Code Playgroud)

Gaz*_*ion 6

我最近遇到了同样的问题,解决方法是将域添加到用户名.

$isAuth = ldap_bind($ldap_conn,$_POST['username'].$ldap_settings['adDomain'], $_POST['password']);
Run Code Online (Sandbox Code Playgroud)

哪里$ldap_settings['adDomain']是"@your_domain"