【问题标题】:Php adLDAP Error - Unable to bind to server: Strong(er) authentication requiredPhp adLDAP 错误 - 无法绑定到服务器:需要强(er)身份验证
【发布时间】:2017-04-15 05:15:25
【问题描述】:

我正在尝试使用PHP adLDAP version 4.04 在公司网络上进行身份验证,但尚未成功。

PHP Version 5.2.4

我试过这个 stackoverflow 帖子 PHP ldap - Strong(er) authentication required,没有运气。

不是此域控制器的管理员;我只需要能够查询。

我可以 ping HOSTNAMEOFDC.domain.location.company.com(我的域控制器的 FQDN)

域控制器是Windows Server 2012 R2 Standard

我已经使用DsQueryPowerShell AD Module 成功查询了这个域控制器,没有问题,也没有我必须手动输入的身份验证。

我的代码:

<?php
require_once("includes/php/adLDAP/src/adLDAP.php");
$username = "domain\\username"; // also tried just "username"
$password = "somepassword";

// All possible settings are listed in this array
$options = array(
        "account_suffix" => "@domain.location.company.com",
//      "admin_username" => $username,
//      "admin_password" => $password,
//      "ad_port" => "636",
//      "base_dn" => "DC=domain,DC=location,DC=company,DC=com",
        "domain_controllers" => array("HOSTNAMEOFDC.domain.location.company.com"),
//      "real_primarygroup" => "",
//      "recursive_groups" => "",
//      "use_ssl" => true
//      "use_tls" => true
);

$adldap = new adLDAP($options);


// $authUser = $adldap->user()->authenticate($username, $password);
$authUser = $adldap->user()->authenticate($username,$password);
if ($authUser) {
    echo "User authenticated successfully";
} else {
    // getLastError is not needed, but may be helpful for finding out why:
    echo $adldap->getLastError() . "<br>";
    echo "User authentication unsuccessful";
}

// Destroy
$adldap->close();
$adldap->__destruct();
?>

我得到错误:

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Strong(er) authentication required in C:\xampp\htdocs\Workspace\Project\scripts\includes\php\adLDAP\src\adLDAP.php on line 712
Strong(er) authentication required
User authentication unsuccessful

然后,当我取消注释 "use_ssl" =&gt; true" 时,我收到此错误:

仅供参考,ssl 已加载到我的 php.ini

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in C:\xampp\htdocs\Workspace\Project\scripts\includes\php\adLDAP\src\adLDAP.php on line 712
Can't contact LDAP server
User authentication unsuccessful

我也尝试取消注释 "use_tls" =&gt; true" 并收到此错误:

Warning: ldap_start_tls() [function.ldap-start-tls]: Unable to start TLS: Connect error in C:\xampp\htdocs\Workspace\Project\scripts\includes\php\adLDAP\src\adLDAP.php on line 638

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in C:\xampp\htdocs\Workspace\Project\scripts\includes\php\adLDAP\src\adLDAP.php on line 712
Can't contact LDAP server
User authentication unsuccessful

【问题讨论】:

  • Ldap 绑定是使用 rdn 而不是用户名完成的,尽管可以将服务器配置为接受用户名。并检查您的协议版本,有些需要设置为版本 3
  • @frz3993 对不起,我的新手,什么是示例 RDN?喜欢Doman\username
  • 更像是uid=12345, ou=people 等DN 的一个组件。一些服务器允许域\用户名。但我不认为这是问题
  • @frz3993 如果您对结果感兴趣,我解决了这个问题。可能需要 10 个小时左右才能解决这个问题

标签: php openssl ldap domaincontroller adldap


【解决方案1】:

此答案与 PHP 5.2 -5.3 有关,此错误已在较新版本中修复(可能)

令人讨厌的是,当 PHP 返回错误 Unable to bind to server: Strong(er) authentication required - 它实际上是在告诉你它需要一个证书或一组证书在你的本地机器 并有一个.conf 文件指向它们。

我创建了一个目录:C:\openldap\sysconf(之前不存在)。

我在C:\openldap\sysconf中创建了文件ldap.conf

在 *nix 中,您可能会将其放在 /etc 或其中的子目录中,但我还没有测试过。

我找到了我们证书的 PEM 文件并将其提取到目录中(PEM 文件基本上是一个文件中的整个证书链)。

ldap.conf内我添加了一行:TLS_CACERT C:\openldap\sysconf\Certs.pem

如果您无法获得 PEM 证书,您可以改用 TLS_REQCERT never这样做时要小心。通过这样做,您将自己暴露在中间攻击的人面前。它不会验证端点。

一旦我这样做了,我就成功绑定了。

如果这不起作用,请尝试将ldap.conf 放入C:\(根级别);它似乎取决于您使用的 PHP 版本 - 它决定在不同的地方查找 ldap.conf

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-19
    • 2016-08-28
    • 1970-01-01
    相关资源
    最近更新 更多