首页 文章

无法使用与php的安全连接绑定到LDAP目录

提问于
浏览
0

Installation Information:
我有两台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

What is the problem:
实际上,我想为AD用户设置密码,所以我的要求是安全连接(LDAPS) . 我可以成功连接到不安全端口(389)上的DC并访问AD数据但我无法使用PHP ldap_bind()函数绑定用户在安全连接上(在端口636上) . 当我运行脚本时,它会给出"ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server"错误 .

Code:

$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="";

2 回答

  • 2

    也许s1.xyz.com无法解决 . 尝试使用ip代替它 . 像ldaps://ip.goes.here:636 .

  • 0

    如果您正在使用SSL(例如ldaps)并且ldap_bind正在抛出'Unable to bind to server:'错误,请检查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查看证书 .

相关问题