doutui8842 2019-04-15 13:27
浏览 119

LDAP连接在PHP 5上运行但不在PHP 7上运行

I want to bind to LDAP server, but when I try to do that in PHP 7 it is not working. Same code however works in PHP 5.

I have code:

$ldapconn = ldap_connect("ldaps://192.168.22.222:636")
or die("Could not connect to LDAP server.");

if ($ldapconn) {
    ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);

    $ldapbind = ldap_bind($ldapconn, 'username', 'password');
    if ($ldapbind) {
        echo "LDAP bind successful...";
    } else {
        echo "LDAP bind failed...";
    }
}

When I execute this code in PHP 5 I get:

LDAP bind successful...

And in LDAP server logs I can see this:

conn=434976 fd=26 ACCEPT from IP=8.8.8.8:43536 (IP=0.0.0.0:636)
conn=434976 fd=26 TLS established tls_ssf=128 ssf=128
conn=434976 op=0 BIND dn="" method=128
conn=434976 op=0 RESULT tag=97 err=0 text=
conn=434976 op=1 UNBIND
conn=434976 fd=26 closed

In PHP 7 I get response:

Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server

and in LDAP logs:

conn=434975 fd=26 ACCEPT from IP=8.8.8.8:50919 (IP=0.0.0.0:636)
conn=434975 fd=26 TLS established tls_ssf=256 ssf=256
conn=434975 fd=26 closed (connection lost)

I found some solutions with disabling cert validation on LDAP server, but I cannot change anything in config of that server.

Can you help me how to bind in PHP 7? I tested that in PHP 7.2 and 7.3 with default config.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥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,如何解決?