- 论坛徽章:
- 0
|
公司用的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
- $ldap_host = "10.1.34.101";
- $base_dn = "DC=xxx.inc,DC=com";
- $filter = "(objectClass=*)";
- $connect = ldap_connect( $ldap_host)
- or exit(">>Could not connect to LDAP server<<");
- ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
- $bind = ldap_bind($connect, $ldap_user, $ldap_pass)
- or exit(">>Could not bind to $ldap_host<<");
-
- $read = ldap_search($connect, $base_dn, $filter)
- or exit(">>Unable to search ldap server<<");
- $info = ldap_get_entries($connect, $read);
- echo $info["count"]." entries returned
- ";
- $ii=0;
- for ($i=0; $ii<$info[$i]["count"]; $ii++){
- $data = $info[$i][$ii];
- echo $data.": ".$info[$i][$data][0]."
- ";
- }
- ldap_close($connect);
复制代码
-
- $Conn = New COM("ADODB.Connection");
- $RS = New COM("ADODB.Recordset");
- $Conn->Provider = "ADsDSOObject";
- $strConn = "10.1.34.101";
- $Conn->Open($strConn);
- $strRS = "Select cn from 'LDAP://10.1.34.101/DC=xxx-inc,DC=com' where objectClass='*' ";
- $RS->Open($strRS, $Conn, 1, 1);
- print_r($RS);
- $RS->Close;
- $Conn->Close;
复制代码 |
|