Php adLDAP 错误 - 无法绑定(bind)到服务器 : Strong(er) authentication required

标签 php openssl ldap domaincontroller adldap

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

PHP 版本 5.2.4

我尝试了这个 stackoverflow 帖子 PHP ldap - Strong(er) authentication required , 运气不好。

不是这个域 Controller 的管理员;我只需要能够查询即可。

我可以 ping HOSTNAMEOFDC.domain.location.company.com(我的域 Controller 的 FQDN)

域 Controller 是 Windows Server 2012 R2 Standard

我已经使用 DsQueryPowerShell AD 模块 成功查询了这个域 Controller ,没有任何问题,也没有我必须手动输入的身份验证。

我的代码:

<?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"=> 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"=> 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

最佳答案

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

恼人的是,当 PHP 返回错误时 Unable to bind to server: Strong(er) authentication required - 它实际上是在告诉你它需要一个或一组证书在你的LOCAL MACHINE 并有一个 .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 代替。 这样做时要小心。这样做会让自己暴露在中间人的攻击之下。它不会验证端点。

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

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

关于Php adLDAP 错误 - 无法绑定(bind)到服务器 : Strong(er) authentication required,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43422469/

相关文章:

php - 将 php 变量发布到新窗口

php - 根据经过身份验证的用户 LARAVEL 设置数据库

php - 为什么它编写的 md5 以及任何语言(如 php、ruby 等)的下载?

openssl - 为什么验证比签名快得多?

ldap - Openldap ppolicy 覆盖不起作用

php - 如何在管理员销售订单列表中获取附属名称?

使用 Websockets 服务器的 SSL/TLS - go lang

php - 如何安全地为 AES CBC 加密生成 IV?

c# - Novell LDAP C# - Novell.Directory.Ldap - 有人让它工作了吗?

具有ldap授权的Git