ldap_search Search LDAP tree php函数分享

ldap_search

(PHP 4, PHP 5)

ldap_search — Search LDAP tree

说明

resource ldap_search ( resource $link_identifier , string $base_dn , string $filter [, array $attributes [, int $attrsonly [, int $sizelimit [, int $timelimit [, int $deref ]]]]] )

Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.

From 4.0.5 on it's also possible to do parallel searches. To do this you use an array of link identifiers, rather than a single identifier, as the first argument. If you don't want the same base DN and the same filter for all the searches, you can also use an array of base DNs and/or an array of filters. Those arrays must be of the same size as the link identifier array since the first entries of the arrays are used for one search, the second entries are used for another, and so on. When doing parallel searches an array of search result identifiers is returned, except in case of error, then the entry corresponding to the search will be FALSE. This is very much like the value normally returned, except that a result identifier is always returned when a search was %ignore_a_1%e. There are some rare cases where the normal search returns FALSE while the parallel search returns an identifier.

参数 link_identifier

An LDAP link identifier, returned by ldap_connect().

base_dn

The base DN for the directory.

filter

The search filter can be simple or advanced, using boolean operators in the format described in the LDAP documentation (see the for full information on filters).

attributes

An array of the required attributes, e.g. array("mail", "sn", "cn"). Note that the "dn" is always returned irrespective of which attributes types are requested.

Using this parameter is much more efficient than the default action (which is to return all attributes and their associated values). The use of this parameter should therefore be considered good practice.

attrsonly

Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour.

sizelimit

Enables you to limit the count of entries fetched. Setting this to 0 means no limit.

Note:

This parameter can NOT override server-side preset sizelimit. You can set it lower though.

Some directory server hosts will be configured to return no more than a preset number of entries. If this occurs, the server will indicate that it has only returned a partial results set. This also occurs if you use this parameter to limit the count of fetched entries.

timelimit

Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.

Note:

This parameter can NOT override server-side preset timelimit. You can set it lower though.

deref

Specifies how aliases should be handled during the search. It can be one of the following:

LDAP_DEREF_NEVER – (default) aliases are never dereferenced. LDAP_DEREF_SEARCHING – aliases should be dereferenced during the search but not when locating the base object of the search. LDAP_DEREF_FINDING – aliases should be dereferenced when locating the base object but not during the search. LDAP_DEREF_ALWAYS – aliases should be dereferenced always.

返回值

Returns a search result identifier or FALSE on error.

更新日志

版本 说明

4.0.5 Parallel searches support was added. 4.0.2 The attrsonly, sizelimit, timelimit and deref were added.

范例

The example below retrieves the organizational unit, surname, given name and email address for all people in "My Company" where the surname or given name contains the substring $person. This example uses a boolean filter to tell the server to look for information in more than one attribute.

Example #1 LDAP search

—-想了解更多的php相关异常处理怎么解决关注 <?php//$dsisavalidlinkidentifierforadirectoryserver

//$personisallorpartofaperson\'sname,eg\"Jo\"

$dn=\"o=MyCompany,c=US\";$filter=\"(|(sn=$person*)(givenname=$person*))\";$justthese=array(\"ou\",\"sn\",\"givenname\",\"mail\");

$sr=ldap_search($ds,$dn,$filter,$justthese);

$info=ldap_get_entries($ds,$sr);

echo$info[\"count\"].\"entriesreturned \";?>

本站无法对海量内容真伪性鉴别,请勿相信本站任何号码,邮件,站外网址等信息,如有需要,请自行甄别。版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至net@163.com举报,一经查实,本站将立刻删除。
(0)
上一篇 2022年8月5日 上午9:18
下一篇 2022年8月5日 上午9:29

相关推荐

  • 酷派5210a(关于酷派5210a的介绍)

    大家好,小节来为大家解答以上的问题。酷派5210a,关于酷派5210a的介绍很多人还不知道,现在让我们一起来看看吧! 1、酷派5210D是一款智能手机。 2、上市于2013年。 本…

    2024年2月25日
  • 爱无悔36集全敏君的孩子在哪(爱无猜)

    大家好,小苏来为大家解答以上问题。爱无悔36集全敏君的孩子在哪,爱无猜很多人还不知道,现在让我们一起来看看吧! 1、ti爱无猜】【ar:摩登新人类插曲】摩登新人类插曲-爱无猜音乐无…

    2024年3月7日
  • 海底捞火锅(海底捞火锅为什么这么贵)

    俗话讲:“一场秋雨,一场凉”。这几天接连下雨,很多人都穿上了小棉袄,我出门冷得直哆嗦。天气太冷,不太想做饭,就带上家人一起去了当地的一家海底捞,你好别说,吃火锅的人可真不少,去的时候还要等位置,海底捞是出了名的客单价高,咋还这么多人喜欢去吃呢?

    2022年5月22日 投稿
  • 300磁力是什么

    300磁力是什么 300磁力是一种磁力计量单位,也叫做磁矩,另一个术语是“特殊比特”(Tbit)。它是一种标准化的单位,用来衡量地球磁场的强度,它的定义是:1磁力(1Tbit)是指…

    2023年7月29日
  • 湖北人特点 湖北有什么风俗习惯 湖北人性格怎么样

    有一句话叫做:一方水土一方人。由于特定的地理环境、民族习惯和传统文化的影响,造成不同地域之间的人们,个人性格有所差别。

    2022年10月26日 投稿
  • 生理期困正常吗(生理期困正常吗)

    很多女性不仅经期腹痛,还有一些嗜睡现象。女性经期犯困正常吗?女性经期犯困怎么办?经期犯困正常吗?经期嗜睡是正常现象。 其实在月经前、后、经期,因为一些生理原因,女性的抵抗力会下降,…

    2022年12月3日
  • ios6(1 3怎么样)

    大家好,小苏来为大家解答以上问题。ios6,1 3怎么样很多人还不知道,现在让我们一起来看看吧! 速度和ios6.1.2没什么区别,第二次更新修复了无需输入密码访问手机和日本地图!…

    2024年2月28日
  • 天然气的密度 使用天然气的好处是啥贵吗

    一、天然气的优点 (一)环保 使用天然气代替燃油作为汽车燃料,可使CO减少90%以上,NOx(氮氧化合物)减少40%左右,CO2 减少20%左右, SO2 减少90%以上,而且不含…

    2022年6月20日
  • excel中间断开

    excel中间断开 Excel中断开是指在使用Excel分析数据时,会出现某些数据缺失,导致分析结果出现中断。这种情况可能是由于数据丢失,也可能是由于某些原因导致某些数据不能够正确…

    2023年8月17日
  • 日本特种部队(日本特种部队)

    您好,今天帅帅来为大家解答以上的问题。日本特种部队,日本特种部队相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、NHK : 陆上自卫队的话…内设 CRF 中央即応…

    2023年1月12日
  • excel方差随机数

    excel方差随机数 Excel方差随机数是指从Excel的随机数功能中产生的一组数字,它们服从指定的方差(或标准差)。方差随机数可以以不同的方式使用,包括进行模拟,以及在统计分析…

    2023年8月13日
  • lumi(关于lumi的介绍)

    大家好,小节来为大家解答以上的问题。lumi,关于lumi的介绍很多人还不知道,现在让我们一起来看看吧! 1、许含光(Lumi),1993年6月11日出生于台湾省台北市,中国台湾流…

    2023年11月12日
  • ThinkPHP框架下整合支付宝支付功能图文教程分享!

    本文实例讲述了ThinkPHP框架下整合支付宝支付功能。分享给大家供大家参考,具体如下: 一.接入配置 根据“快速接入”中的流程,两者大同小异,都是进行: 虽然官方文档已经做的很详…

    2022年8月2日 投稿
  • 张衡是什么家(关于张衡是什么家的介绍)

    大家好,小节来为大家解答以上的问题。张衡是什么家,关于张衡是什么家的介绍很多人还不知道,现在让我们一起来看看吧! 1、张衡(78年—139年),字平子。 2、汉族,南阳西鄂(今河南…

    2024年3月9日
  • 上游企业与下游企业的关系(上游企业和下游企业是什么意思)

    您好,今天帅帅来为大家解答以上的问题。上游企业与下游企业的关系,上游企业和下游企业是什么意思相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、区别:从生产链角度来讲,上游企业是…

    2024年2月2日

发表回复

登录后才能评论