gpt4 book ai didi

PHP LDAP 与 AD LDS 的连接

转载 作者:搜寻专家 更新时间:2023-10-31 22:02:21 24 4
gpt4 key购买 nike

我正在尝试编写一些 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 手册,这似乎是正确的。我在这一点上感到难过。我可以打开任何其他调试吗?

这是它返回的错误:

Warning: 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($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);

关于PHP LDAP 与 AD LDS 的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26267466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com