gpt4 book ai didi

PHP LDAPS 连接到 AD

转载 作者:太空宇宙 更新时间:2023-11-03 14:22:54 25 4
gpt4 key购买 nike

使用 PHP 7.4 通过 SSL 连接到 Windows AD

$ldaphost = "ldaps://...";
$ldapUsername = "CN=supervisor,OU=test_Users,DC=test,DC=org";
$ldapPassword = "xxxx";


$ds = ldap_connect($ldaphost,636);
echo $ds;

if (!ldap_start_tls($ds)) {
print "Could not start secure TLS connection";
}else {
// now we need to bind to the ldap server
$bth = ldap_bind($ds, $ldapUsername, $ldapPassword) or die("\r\nCould not connect to LDAP server\r\n");
}

错误:ldap_start_tls():无法启动 TLS:无法联系 LDAP 服务器

调试后:ldap_connect 按预期返回 id process。我尝试使用 GUI 工具进行连接并且连接成功,这意味着我消除了证书问题。我感谢解决此问题的任何想法谢谢

最佳答案

您应该要么使用ldaps TLS。到目前为止,首选方式是根据 LDAPv3 的 TLS。因此,您将使用 ldap:// 连接到不安全的后端,然后调用 ldap_start_tls 作为第一个命令(可能在某些 ldap_set_option 调用之后) 但肯定是在调用 ldap_bind 之前。

您的问题可能是,与 LDAP 服务器的连接根本无法从有问题的机器上工作。由于 ldap_connect 实际上并没有连接,而只是创建了一个可用于进行实际连接的句柄,连接错误通常在需要实际连接的第一次调用时出现(在您的情况下 ldap_start_tls).因此,请检查您的服务器是否真的可以从相关机器的给定端口上访问,例如通过调用 telnet servernameOrIp port 或使用 cli-ldap-tool

另一件事是,您错误地使用了 ldap_connect。您应该像这样将端口添加到 ldap-uri:ldaps://example.com:636 as specified in the docs .如果您使用 LDAP-URL,端口参数将被忽略。

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

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