[英]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.