Kol*_*yon 7 php openssl ldap domaincontroller adldap
我试图使用PHP adLDAP版本4.04 在企业网络上进行身份验证,但尚未成功.
PHP Version 5.2.4
我试过这个stackoverflow后发布的PHP ldap - 需要强(呃)身份验证,没有运气.
我不是这个域控制器的管理员; 我只需要能够查询.
我能ping HOSTNAMEOFDC.domain.location.company.com(我的域控制器的FQDN)
域控制器是一个Windows Server 2012 R2 Standard.
我已成功查询此域控制器使用DsQuery并PowerShell 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();
?>
Run Code Online (Sandbox Code Playgroud)
我收到错误:
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
Run Code Online (Sandbox Code Playgroud)
然后,当我取消注释时,"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
Run Code Online (Sandbox Code Playgroud)
我也尝试取消注释"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
Run Code Online (Sandbox Code Playgroud)
此答案与PHP 5.2 -5.3有关,此错误已在较新版本中修复(可能是)
令人讨厌的是,当PHP吐出错误无法绑定到服务器:需要强身份验证 -实际上是在告诉您它需要本地机器上的一个证书或一组证书,并有一个.conf指向它们的文件。
我创建了一个目录:(C:\openldap\sysconf之前不存在)。
我把文件放进去 ldap.conf了C:\openldap\sysconf
在* nix中,您可能会将其放在其中/etc或子目录中,但是我尚未对此进行测试。
我去找到了我们的证书的PEM文件,并将其提取到目录中(一个PEM文件基本上是整个证书链的一个文件)。
在其中ldap.conf添加以下行:TLS_CACERT C:\openldap\sysconf\Certs.pem
如果无法获得PEM证书,则可以TLS_REQCERT never改用。这样做时要小心。通过执行此操作,您将自己暴露给处于中间攻击的男人。它不会验证端点。
完成此操作后,我便成功绑定了。
如果不工作,尝试把ldap.conf在C:\(根级); 它似乎取决于您使用的PHP版本-它决定在不同的地方查找ldap.conf。
| 归档时间: |
|
| 查看次数: |
2160 次 |
| 最近记录: |