0

安装信息:
我有两台 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="";
4

2 回答 2

2

如果您使用 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 查看您的证书。

于 2012-01-12T17:16:50.300 回答
0

也许 s1.xyz.com 无法解决。改用 ip 试试。就像 ldaps://ip.goes.here:636。

于 2012-01-12T13:53:19.333 回答