[英]can not bind to the LDAP directory with secure connection with php
安裝信息:
我有兩台Windows服務器。 一個(Windows Server 2008 R2)是具有Active Directory(AD)的域控制器(DC)。它的名稱是s1.xyz.com。 第二個(Windows Server 2003 R2)服務器正在運行IIS,PHP.SSL證書安裝在第二個服務器上。
我已在DC服務器上安裝Active Directory證書服務以充當證書頒發機構(CA),並使用以下鏈接啟用LDAP over SSL(LDAPS):
http://www.christowles.com/2010/11/enable-ldap-over-ssl-ldaps-on-windows.html
問題是什么:
實際上,我想為AD用戶設置密碼,所以我的要求是安全連接(LDAPS)。 我可以成功連接到不安全端口(389)上的DC並訪問AD數據但我無法使用PHP ldap_bind()函數綁定用戶在安全連接上(在端口636上)。 當我運行腳本時,它給出“ldap_bind()[function.ldap-bind]:無法綁定到服務器:無法聯系LDAP服務器”錯誤。
碼:
$ip="xxx.xxx.xxx.xx";
$ldaps_url="ldaps://s1.xyz.com:636/";
$ldap_url="s1.xyz.com";
$ldapUsername ="Administrator@xyz.com";
$ldapPassword="x1y1z1";
$ds=ldap_connect($ldaps_url);
//$ds=ldap_connect($ip,636);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ds, LDAP_OPT_REFERRALS,0);
$bth=ldap_bind($ds, $ldapUsername, $ldapPassword);
ldap_unbind($ds);
$ds="";
如果您正在使用SSL(例如ldaps)並且ldap_bind正在拋出“無法綁定到服務器:”錯誤,請檢查ldap_connect中使用的主機名是否與LDAP服務器上的SSL證書中的“CN”匹配。 例如:
<?
ldap_connect('ldaps://ldap01');
// 'ldap01' should match the CN in your LDAP server's SSL cert, otherwise the subsequent ldap_bind() will throw a bind error
?>
您可以使用Microsoft MMC查看證書。
也許s1.xyz.com無法解決。 嘗試使用ip代替它。 像ldaps://ip.goes.here:636。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.