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 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序