日期:2011-08-22 浏览次数:21789 次
- <?php
- //phpinfo();
- $host = "******:389";
- $user = "**@**";
- $pswd = "*****";
- $ad = ldap_connect($host) or die( "Could not connect!" );
- if($ad){
- //设置参数
- ldap_set_option ( $ad, LDAP_OPT_PROTOCOL_VERSION, 3 );
- ldap_set_option ( $ad, LDAP_OPT_REFERRALS, 0 );
- // bool ldap_bind ( resource $link_identifier [, string $bind_rdn = NULL [, string $bind_password = NULL ]] )
- $bd = ldap_bind($ad, $user, $pswd) or die ("Could not bind");
- echo "ldap_bind success";
- //指定需要获取的用户属性
- $attrs = array("displayname","cn");
- //指定需查询的用户范围
- $filter = "(objectclass=*)";
- //ldap_search ( resource $link_identifier , string $base_dn , string $filter [, array $attributes [, int $attrsonly [, int $sizelimit [, int $timelimit [, int $deref ]]]]] )
- $search = ldap_search($ad, 'DC=**,DC=**,DC=**', $filter, $attrs,0,0,0) or die ("ldap search failed");
- $entries = ldap_get_entries($ad,