我在使用 Windows 连接到安全 LDAP 服务器时遇到问题,而且我在网上到处都看到同样的情况,但到目前为止还没有有效的解决方案。
我尝试过同时使用 IIS 和 WAMPSERVER。我已将 libeay32.dll 和 ssleay32.dll 放入 SYSTEM32 目录中并启用 LDAP 扩展。
这是我的代码:
putenv('LDAPTLS_REQCERT=never');
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$resource = ldap_connect("ldaps://{redacted}/", 636) or die ("Could not connect.");
ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)
$bound = ldap_bind($resource, "{redacted}\ldap", "****");
echo ldap_error($resource);
I get Can't contact LDAP server
来自 ldap_error 和 PHP 警告Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in C:\wamp\www\ldapTest.php
我尝试连接的服务器正在运行 Active Directory,并且我已确认可以使用其他 LDAP 工具进行连接。我知道这台服务器的证书有问题 - 我正在使用的 LDAP 工具说The server you are trying to connect to is using a certificate which could not be verified! - Issuer certificate not found
我怀疑错误的证书导致了绑定问题,这就是我尝试 LDAPTLS_REQCERT=never 的原因。