LDAP操作错误 [英] LDAP Operations error

查看:214
本文介绍了LDAP操作错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ldap连接有问题.

I have a problem with ldap connection.

$hostname="ldap://sub.domain.com";
$ds=ldap_connect($hostname, 389);
ldap_set_option ($ds, LDAP_OPT_REFERRALS, 0) or die('Unable to set LDAP opt referrals');
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version');

if ($ds)
{
$dn = "OU=Users,OU=ro,DC=sub,DC=domain,DC=com";

if (!($ldapc=ldap_bind($ds))) { 
    echo "<p>Error:" . ldap_error($ds) . "</p>"; 
    echo "<p>Error number:" . ldap_errno($ds) . "</p>"; 
    echo "<p>Error:" . ldap_err2str(ldap_errno($ds)) . "</p>"; 
    die;
} 

$attributes = array("sn");
$filter = "(sn=*)";
$result = ldap_search($ds, $dn, $filter, $attributes);

echo $result;
$info = ldap_get_entries($ds, $result);
for ($i=0; $i < $info["count"]; $i++) {
    echo $info[$i]["ou"][0];
}
} else {
    echo "<h4>Unable to connect to LDAP server</h4>";
}

ldap_unbind($ds);

ldap任何匿名连接都有效,因为我在AD浏览器中对其进行了测试,一切都很好. 在此代码中,它停止在

The ldap any anonymous connection works because I test it in a AD browser and everything is fine. In this code it stops at

ldap_search($ds, $dn, $filter, $attributes);

我收到警告:

警告:ldap_search():搜索:第38行的.. \ index.php中的操作错误

Warning: ldap_search(): Search: Operations error in ..\index.php on line 38

我真的不知道导致此错误的原因是什么,感谢您的帮助.

I don't really know what can be the cause of this error, I appreciate your help.

推荐答案

要将其从未答复的列表中删除:

To get it off the unanswered list:

我发现了问题,这是绑定问题.服务器接受匿名绑定,但不接受搜索.并与用户和通行证工作,但我犯了一个错误.对于用户,我认为只是de Windows的用户名而不是AD的所有位置,现在可以了.

I found the problem, was the bind problem. The server accepts the anonymous bind but not the search. And with an user and pass worked but i was making a mistake. For user i considered just de windows's username not the all location from AD, now it works.

这篇关于LDAP操作错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆