免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3002 | 回复: 0
打印 上一主题 下一主题

[ldap] 求救啊,LDAP search老提示出错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-08 11:20 |只看该作者 |倒序浏览
公司用的exchange ldap
我需要用在ldap中验证用户名密码是否正确。

我对ldap完全不了解。下载了一个软件叫 “ldap客户端工具.exe”, 能连上,并能看到里面的结构

但是我在php里,按php手册的提供的方法, ldap_connect    ldap_bind 都提示成功,但是  ldap_search 怎么写都出错

提示:  ldap_search() [function.ldap-search]: Search: Operations error

base_dn 参数应该是对的,因为我用 ldap客户端工具.exe 软件可以连上。帮忙啊。

我msn: kenvinqu@msn.com


  1. $ldap_host = "10.1.34.101";
  2. $base_dn = "DC=xxx.inc,DC=com";
  3. $filter = "(objectClass=*)";


  4. $connect = ldap_connect( $ldap_host)
  5.         or exit(">>Could not connect to LDAP server<<");
  6. ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
  7. ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
  8. $bind = ldap_bind($connect, $ldap_user, $ldap_pass)
  9.      or exit(">>Could not bind to $ldap_host<<");


  10. $read = ldap_search($connect, $base_dn, $filter)
  11.      or exit(">>Unable to search ldap server<<");


  12. $info = ldap_get_entries($connect, $read);
  13. echo $info["count"]." entries returned

  14. ";
  15. $ii=0;
  16. for ($i=0; $ii<$info[$i]["count"]; $ii++){
  17.    $data = $info[$i][$ii];
  18.    echo $data.":&nbsp;&nbsp;".$info[$i][$data][0]."
  19. ";
  20. }
  21. ldap_close($connect);

复制代码



  1. $Conn = New COM("ADODB.Connection");
  2. $RS = New COM("ADODB.Recordset");
  3. $Conn->Provider = "ADsDSOObject";

  4. $strConn = "10.1.34.101";
  5. $Conn->Open($strConn);
  6. $strRS = "Select cn from 'LDAP://10.1.34.101/DC=xxx-inc,DC=com' where objectClass='*' ";
  7. $RS->Open($strRS, $Conn, 1, 1);

  8. print_r($RS);


  9. $RS->Close;
  10. $Conn->Close;

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP