我試圖使用PHP adLDAP version 4.04在公司網絡上進行身份驗證,但沒有成功。Php adLDAP錯誤 - 無法綁定到服務器:需要強(er)身份驗證
PHP Version 5.2.4
我想這個計算器張貼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
Ldap綁定是使用rdn not用戶名完成的,儘管服務器可以配置爲接受用戶名。並檢查你的協議版本,有些將需要設置爲版本3 – frz3993
@ frz3993請原諒我的新手,這將是一個示例RDN?像'Doman \ username'? –
更像是DN的組件,如'uid = 12345,ou = people'。某些服務器允許域\用戶名。但我不認爲這是問題 – frz3993