ldap filter for distinguishedName(用于区分名称的 ldap 过滤器)
问题描述
我正在使用以下代码成功地在我们的 Active Directory 中查询用户:
I am successfully querying our Active Directory for a user with the following code:
$filter = (&(objectCategory=person)(samaccountname=someusername));
$fields = array("samaccountname","mail","manager","department","displayname","objectGUID");
$user = ldap_search($ldapconnection, $baseDn, $filter, $fields);
生成的数组为 manager
属性提供此值:
The resulting array gives this value for the manager
attribute:
CN=McBossy, Boss,OU=Users,OU=CentralOffice,DC=ds,DC=example,DC=com
对我来说,这看起来像是一个杰出的名字.但是当我尝试查询经理的记录时,
This looks like a distinguishedName to me. But when I try to query for the manager's record,
$filter = (&(objectCategory=person)(dn='CN=McBossy, Boss,OU=Users,OU=CentralOffice,DC=ds,DC=example,DC=com'));
$manager = ldap_search($ldapconnection, $baseDn, $filter, $fields);
查询失败,PHP 警告:ldap_search(): Search: Bad search filter
我尝试了多种可能性,包括不同的引用、更多的括号、使用 distinguishedName
而不是 dn
等.
I've tried a number of possibilities including different quotation, more parentheses, using distinguishedName
rather than dn
, etc.
我做错了什么,获取经理记录的正确方法是什么?
What am I doing wrong and what is the right way to get the manager's record?
推荐答案
dn
不是属性.过滤器中只能使用属性类型、OID 和名称.
dn
is not an attribute. Only attribute types, OIDs, and names can be used in filters.
当您获得 manager
属性时,要获得作为经理的 DN 的属性,请使用 manager
属性的值作为搜索中的基本对象要求.将搜索范围设置为 BASE
,将过滤器设置为 (&)
或 (objectClass=*)
并请求所需的属性.然后将搜索请求传输到服务器并解释响应.
When you get the manager
attribute, to get the attributes for the DN that is the manager, use the value of the manager
attribute as the base object in a search request. Set the scope of the search to BASE
, the filter to either (&)
or (objectClass=*)
and request the attributes required. Then transmit the search request to the server and interpret the response.
这篇关于用于区分名称的 ldap 过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用于区分名称的 ldap 过滤器
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01