我尝试使用以下代码在 PHP 中连接到 LDAP:
$ds = ldap_connect("122.134.124.2", 389);
$login = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="670b08000e092703080a060e09490b0804060b" rel="noreferrer noopener nofollow">[email protected]</a>";
$password = "password";
if ($ds)
{
$r = ldap_bind($ds, $login, $password);
$sr = ldap_search($ds, "dc=domain,dc=local", "cn=m*");
}
else
echo "Impossible to connect to the LDAP server.";
我收到此错误: ldap_search(): 搜索:test.php 第 8 行出现操作错误(包含 ldap_search 函数的行)。
但是连接有效,我输入了 ldap_search 函数的所有参数。
最佳答案
解决方案是将这些行添加到代码中:ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
关于php ldap_search() : Search: Operations error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31564499/