脚本宝典收集整理的这篇文章主要介绍了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 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);
我收到警告:
我发现问题,是绑定问题.服务器接受匿名绑定,但不接受搜索.并且用户和通行证工作,但我犯了一个错误.对于用户,我认为只是de windows的用户名,而不是AD的所有位置,现在它的作品.
以上是脚本宝典为你收集整理的php – LDAP操作错误全部内容,希望文章能够帮你解决php – LDAP操作错误所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。