【问题标题】:PHP LDAP connection with AD LDS与 AD LDS 的 PHP LDAP 连接
【发布时间】:2014-10-08 22:25:57
【问题描述】:

我正在尝试编写一些 PHP 来查询 AD LDS/LDAP (2012 R2) 实例,但无法连接。我目前将其设置为未加密的连接(prod 将是 ssl/tls)。

当前故障排除:

  • 我可以通过 ldapsearch 连接到我的 LDAP 实例并执行查询
  • 我可以在我的 windows 盒子上通过 LDP 进行连接
  • 我可以从我的 nix 盒 ping LDAP 服务器和 telnet 到端口。
  • 为用户名尝试了完整的 rdn
  • 尝试 URI(ldap://ldapserver:50001 或将端口作为它自己的 var 传递)

我已经重写了代码一百万次,认为这是某种语法错误或无法正确传递的东西。 $ldapconn 返回“Resource id #2”,根据 PHP 手册,这似乎是正确的。在这一点上我很难过。我可以打开任何其他调试吗?

这是它正在返回的错误:

警告:ldap_bind(): Unable to bind to server: Can't contact LDAP server in /usr/share/nginx/html/logintest3.php on line 20

以下是相关代码:

<?php

// all the debugging
ini_set('display_errors', 'On');
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

$ldapuser = "ldapbind";
$ldappassword = "ldapbinder";
$ldapserver = "ldapserver";
$ldapport = 50001;

// connect to ldap server
$ldapconn = ldap_connect($ldapserver, $ldapport)
or die("Could not connect to $ldapserver");

// check if ldap_connect returned a resource value 
if($ldapconn) echo "$ldapconn";

// attempting bind
$ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappassword);

echo "Ldap connection debug: " . ldap_error($ldapconn) . "\n";

?>

【问题讨论】:

  • 开启ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7)
  • 试试这些选项:ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  • 您是否验证了端口 50001 实际上是未加密的 LDAP?在我的站点上,50000 是 LDAP,50001 是 LDAPS。我需要在 URL 中指定端口,ldap_connect 的第二个参数无效。我还需要为绑定用户输入完整的 DN 字符串。

标签: php authentication ldap


【解决方案1】:

试试

ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);

【讨论】:

    猜你喜欢
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    相关资源
    最近更新 更多