php ldap_search操作错误

时间:2014-03-09 21:50:56

标签: php ldap centos windows-server-2008-r2

我想使用以下php脚本来检索设置了“proxyAddresses”属性的AD用户(Windows 2008R2):

<?php
$ldaprdn  = 'ldapbind@test.net';
$ldappass = 'testpass';

$ldapconn = ldap_connect("ldap://10.1.20.254:389")
    or die("Could not connect to LDAP server.");

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

if ($ldapconn) {
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); 
    if ($ldapbind) {
        echo "LDAP bind successful...\n";
        $result = ldap_search($ldapconn, "CN=Users,DN=test,DN=net", "(proxyAddresses=*)")
        or die ("Error in serach query: " . ldap_error($ldapconn));
        $data = ldap_get_entries($ldapconn, $result);
        print_r($data);
    } else {
        echo "LDAP bind failed...";
    }
}
?>

它绑定成功,但后来我收到警告和错误消息:

PHP Warning:  ldap_search() Operations error in ..... on line .. (the ldap_search line)

Error in search query: Operations error

当我在控制台上执行ldapsearch时:

ldapsearch -h 10.1.20.254 -p 389 -D 'ldapbind@test.net' -w 'testpass' -b 'CN=Users,DC=test,DC=net' '(proxyAddresses=*)' cn proxyAddresses mail

我得到了理想的结果。

它正在运行“CentOS版本6.4(最终版)。

提前致谢

0 个答案:

没有答案