douruyun8153 2014-10-08 22:25
浏览 197

与AD LDS的PHP LDAP连接

I'm trying to write some PHP to query an AD LDS/LDAP (2012 R2) instance and I can't get the thing to connect. I currently have it set up as an unencrypted connection (prod will be ssl/tls).

Current troubleshooting:

  • I can connect to my LDAP instance via ldapsearch and perform queries
  • I can connect via LDP on my windows boxes
  • I can ping the LDAP server and telnet to the port from my nix box.
  • Tried full rdn for the username
  • Tried URI (ldap://ldapserver:50001 or passing the port as it's own var)

I've rewritten the code a million times thinking it was a syntax error of some sort or something not passing correctly. $ldapconn is returning "Resource id #2", which per the PHP manual appears to be correct. I'm stumped at this point. Is there any additional debugging I can turn on?

Here is the error it's kicking back:

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

Here is the relevant code:

<?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) . "
";

?>
  • 写回答

1条回答 默认 最新

  • dongyunqin7307 2014-10-08 22:40
    关注

    try

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog