加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – LDAP操作错误

发布时间:2020-12-13 16:25:57 所属栏目:PHP教程 来源:网络整理
导读:我有一个ldap连接的问题. $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
我有一个ldap连接的问题.
$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浏览器中测试,一切都很好.
在这段代码中,它停止在

ldap_search($ds,$attributes);

我收到警告:

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

我真的不知道这个错误的原因是什么,我感谢你的帮助.

要取消应答的列表:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读