无法绑定到与php安全连接的LDAP目录
安装信息:
我有两个Windows服务器。一个(Windows Server 2008 R2)是具有Active Directory(AD)的域控制器(DC),其名称为s1.xyz.com。第二台(Windows Server 2003 R2)服务器运行IIS,PHP.SSL证书安装在第二台服务器上。
无法绑定到与php安全连接的LDAP目录
我已经安装了DC服务器上的Active Directory证书服务使用以下链接作为一个证书颁发机构(CA),并启用LDAP通过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 ="[email protected]";
$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使用的主机名相匹配的“CN” SSL证书中的LDAP服务器。例如:
<?
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查看您的证书。
Thanks @ JPBlanc.I使用MS MMC查看我的SSL证书,其主题字段值为“s1.xyz.com”,实际上我想要绑定它。现在我的SSL证书位于证书(本地计算机) - > Personal- > MMC向导中的证书文件夹。我有多个证书,我不知道究竟是什么问题.plz的帮助。 – sandy 2012-01-13 05:36:04
你确定DC有这个端口打开吗?如果它响应,请尝试telnet s1.xyz.com 636。 – rkosegi 2012-01-12 13:39:30
重复http://*.com/questions/5258556/problems-with-secure-bind-to-active-directory-using-php? – 2012-01-12 14:00:18