我正在尝试使用PHP adLDAP 4.04 版 在公司网络上进行身份验证,但尚未成功。
PHP Version 5.2.4
我试过这个stackoverflow post PHP ldap - Strong(er) authentication required,没有运气。
我不是此域控制器的管理员;我只需要能够查询。
我能够 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();
?>
我得到错误:
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