php - ldap_search():搜索:操作错误

问题描述 投票:0回答:1

我一直在尝试几乎所有方法来解决这个问题,但遗憾的是我做不到,我开始认为这是我组织内部的事情,但当我询问每个人时,他们告诉我没有什么可以阻止你,所以也许我是遗漏了什么: 我的目标是在活动目录树顶部的 LDAP 中搜索任何用户或组,我有 php 版本 8.1,由于 ldap_search 问题出现在那里,我尝试升级到版本 8.3.6。

<?php
{
    $ldaprdn = "username";
    $ldappass = 'password';
    
    $ldapconn = ldap_connect("ldapserver") or die ("could not connect to LDAP server");
    if($ldapconn)
    {
        print("connected");
        $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
        $user_to_search = "My_User";
        if($ldapbind)
        {
            print("binded");
            $filter = "(samaccountname=$user_to_search*)";
            $justthese = array("samaccountname");
            $result = ldap_search($ldapconn, "DC=Top,DC=OrganizationTree", $filter, $justthese);
            $entries = ldap_get_entries($ldapconn, $result);
            print_r($entries);
        }
    }
}
?>

这是我现在得到的错误: php warnionig: ldap_search(): 搜索:操作错误......在线

必须感谢任何能够阐明这个问题的人...... 我还尝试在 php 中启用“调试模式”以获取有关此问题的更多信息,但遗憾的是我没有获得任何更多相关信息。

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

error_reporting(E_ALL);
ini_set('display_errors', 'on');
php active-directory ldap
1个回答
0
投票

嗯,我的问题确实没有答案,这要么是我们在假期期间修复的网络问题,要么是@Cyclonecode 建议添加的问题

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); 
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);

进入我的代码。 到目前为止一切顺利,数据正在不间断且顺利地拉取。 感谢所有花时间阅读并协助解决我的问题的人。

© www.soinside.com 2019 - 2024. All rights reserved.