PHP警告:ldap_search()

时间:2018-10-15 04:02:02

标签: php active-directory ldap-query

我正在尝试在https://github.com/mprahl/ADReset/上实现一个名为ADReset的github项目。

我解决了一些已发现的问题,但是尝试设置管理安全组时遇到了问题。查看apache错误日志,我看到以下内容:

[Mon Oct 01 04:32:25.705508 2018] [php7:warn] [pid 13411] [client XXXXXX:50840] 
PHP Warning: ldap_search(): Search: Operations error in 
/var/www/adreset/resources/classes/AD.php on line 93, 
referer: http://XXXXXX/settings/systemsettings.php

看第93行,它是类中函数的一部分。功能如下:

public function search($query) {
        if (isset($query)) {
            if ($result = ldap_search($this->ad_connection, 
                $this->connectionSettings['baseDN'], $query)) {
                $data = ldap_get_entries($this->ad_connection, $result);
                return $data;
            }

            else {
                return array();
            }
        }

试图找出问题的根源,我添加了一些错误日志记录,现在的功能是:

        public function search($query) {
        if (isset($query)) {
            error_log(print_r($query,true));
            error_log(print_r("AD Connection Stuffs " . ldap_error($this->ad_connection),true));
            error_log(print_r($this->connectionSettings['baseDN'],true));
            $result = ldap_search($this->ad_connection, $this->connectionSettings['baseDN'], $query);
            if ($result) {
                $data = ldap_get_entries($this->ad_connection, $result);
                return $data;
            }

            else {
                return array();
            }
        }

通过ui运行脚本时,看到以下错误:

[Sun Oct 14 22:41:33.128492 2018] [php7:notice] [pid 3236] [client xxx.xxx.xxx.xxx:59470] (&(objectClass=group)(sAMAccountName=test)), referer: http://XXXX.XXXX.com/settings/systemsettings.php
[Sun Oct 14 22:41:33.128590 2018] [php7:notice] [pid 3236] [client xxx.xxx.xxx.xxx:59470] AD COnnection Stuffs Success, referer: http://XXXX.XXXX.com/settings/systemsettings.php
[Sun Oct 14 22:41:33.128608 2018] [php7:notice] [pid 3236] [client xxx.xxx.xxx.xxx:59470] DC=XXXX,DC=com, referer: http://XXXX.XXXX.com/settings/systemsettings.php
[Sun Oct 14 22:41:33.128990 2018] [php7:warn] [pid 3236] [client xxx.xxx.xxx.xxx:59470] PHP Warning:  ldap_search(): Search: Operations error in /var/www/adreset/resources/classes/AD.php on line 97, referer: http://XXXX.XXXX.com/settings/systemsettings.php
[Sun Oct 14 22:41:33.129114 2018] [php7:notice] [pid 3236] [client xxx.xxx.xxx.xxx:59470] , referer: http://XXXX.XXXX.com/settings/systemsettings.php

所以,我把它分解了。 $ this-> ad_connection返回“成功”的结果,基本DN返回我正在使用的AD服务器的正确基本DN,甚至查询正确。为了再次检查查询是否有效,我使用了Softerra LDAP浏览器并进行了搜索。我完全不知道为什么这个功能失败了。任何帮助/方向将不胜感激。

0 个答案:

没有答案
相关问题