php ldap_search() : Search: Operations error

标签 php ldap

我尝试使用以下代码在 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/

相关文章:

php - SVG 到 CDR 转换器

ldap - 当用户在组中时,memberOf 属性不存在(dirsrv,CentOS6.2)

c# - 将大量用户添加到 Active Directory 中的组

java - 根据 sn 和给定名称的 3 个字符动态分配唯一的 UID 值

java - 如何将所有 memberOf 属性分配给 LDAP 中的特定用户

php - 以表格形式请求许可证

javascript - 使用 PHP 和 JavaScript 更新 DOM 中的用户参与者列表,就像 GitHub Issues 所做的那样

java - 使用ajax从php页面调用servlet

php - php md5 中的简单登录表单?

java - 使用UnboundID的@LDAPGetter和@LDAPSetter