用于搜索多个特定 OU 的 LDAP 根查询语法
我需要运行一个 LDAP 查询来搜索根查询中的两个特定组织单位 (OU),但我遇到了困难。我尝试了下面的以下查询,但都没有成功:
(|(OU=Staff,DC=my,DC=super,DC=org)(OU=Vendors,DC=my,DC=super,DC=org))
((OU=Staff,DC=my,DC=super,DC=org) | (OU=Vendors,DC=my,DC=super,DC=org))
我的问题是;是否可以在单个查询中查询多个 OU? 假设这是根 LDAP 查询中此类表达式的正确语法。
I need to run a single LDAP query that will search through two specific organization units (OU) in the root query however I'm having a tough go of it. I've tried the following queries below and neither were successful:
(|(OU=Staff,DC=my,DC=super,DC=org)(OU=Vendors,DC=my,DC=super,DC=org))
((OU=Staff,DC=my,DC=super,DC=org) | (OU=Vendors,DC=my,DC=super,DC=org))
My question is; is it possible to query more than one single OU in a single query? Assuming that it is what the proper syntax for this type of expression in the root LDAP query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你可以!!!简而言之,使用它作为连接字符串:
与您的搜索过滤器一起使用,例如,
它将在所谓的 全局目录,在我们的环境中开箱即用。
而不是使用多个 OU 在我们的环境中无法工作的已知/常见其他版本(或其组合):(
我是开发人员,而不是 AD/LDAP 专家:)该死,我一直在搜索对于这个解决方案,我花了将近 2 天的时间,几乎放弃了,习惯了我可能必须手动实现这个显然非常常见的场景(使用 Jasperserver/Spring security(/Tomcat))。
(所以,如果其他人或我将来再次遇到这个问题,这将是一个提醒:O))
这里是我在研究过程中发现的一些其他相关线程,这些线程大多没有什么帮助:
在这里,我将提供我们的匿名 Tomcat LDAP 配置,以防它可能有帮助
(
/var/lib/tomcat7/webapps/jasperserver/WEB-INF/applicationContext-externalAUTH-LDAP.xml
):You can!!! In short use this as the connection string:
together with your search filter, e.g.
That will search in the so called Global Catalog, that had been available out-of-the-box in our environment.
Instead of the known/common other versions (or combinations thereof) that did NOT work in our environment with multiple OUs:
(I am a developer, not an AD/LDAP guru:) Damn I had been searching for this solution everywhere for almost 2 days and almost gave up, getting used to the thought I might have to implement this obviously very common scenario by hand (with Jasperserver/Spring security(/Tomcat)).
(So this shall be a reminder if somebody else or me should have this problem again in the future :O) )
Here some other related threads I found during my research that had been mostly of little help:
And here I will provide our anonymized Tomcat LDAP config in case it may be helpful
(
/var/lib/tomcat7/webapps/jasperserver/WEB-INF/applicationContext-externalAUTH-LDAP.xml
):答案是否定的,你不能。为什么?
因为 LDAP 标准将 LDAP-SEARCH 描述为具有 4 个参数的函数:
您对过滤器感兴趣。 此处提供了摘要(它是由 Microsoft 为 Active Directory 提供的,来自标准)。该过滤器由
Attribute Operator Value
类型的表达式以布尔方式组成。所以你给的过滤器没有任何意义。
从理论上来看,ExtensibleMatch 允许在 DN 路径上使用 buildind 过滤器,但事实并非如此受活动目录支持。
据我所知,必须使用AD中的属性来区分两个OU中的用户。
它可以是任何现有的鉴别器属性,或者例如从
organizationalPerson
类继承的名为 OU 的属性。您可以设置它(它不是自动的,如果您移动用户,也不会维护),某些用户使用“staff”,其他用户使用“vendors”,他们使用过滤器:The answer is NO you can't. Why?
Because the LDAP standard describes a LDAP-SEARCH as kind of function with 4 parameters:
You are interested in the filter. You've got a summary here (it's provided by Microsoft for Active Directory, it's from a standard). The filter is composed, in a boolean way, by expression of the type
Attribute Operator Value
.So the filter you give does not mean anything.
On the theoretical point of view there is ExtensibleMatch that allows buildind filters on the DN path, but it's not supported by Active Directory.
As far as I know, you have to use an attribute in AD to make the distinction for users in the two OUs.
It can be any existing discriminator attribute, or, for example the attribute called OU which is inherited from
organizationalPerson
class. you can set it (it's not automatic, and will not be maintained if you move the users) with "staff" for some users and "vendors" for others and them use the filter:这很简单。只需更改端口即可。使用 3268 而不是 389。如果您的域名 DOMAIN.LOCAL,请在搜索中输入 DC=DOMAIN,DC=LOCAL
端口 3268: 此端口用于专门针对全局编录的查询。发送到端口 3268 的 LDAP 请求可用于搜索整个林中的对象。但是,只能返回标记为复制到全局编录的属性。
端口 389:此端口用于向域控制器请求信息。发送到端口 389 的 LDAP 请求只能用于搜索全局编录主域内的对象。然而,应用程序有可能获得搜索对象的所有属性。
It's simple. Just change the port. Use 3268 instead of 389. If your domain name DOMAIN.LOCAL, in search put DC=DOMAIN,DC=LOCAL
Port 3268: This port is used for queries that are specifically targeted for the global catalog. LDAP requests sent to port 3268 can be used to search objects in the entire forest. However, only the attributes marked for replication to the global catalog can be returned.
Port 389: This port is used for requesting information from the Domain Controller. LDAP requests sent to port 389 can be used to search objects only within the global catalog’s home domain. However, the application can possible to obtain all of the attributes searched objects.
我认为这对于 AD 来说是不可能的。据我所知,distinguishedName 属性是唯一包含您要搜索的 OU 片段的属性,因此您需要一个通配符来获取这些 OU 下的对象的结果。遗憾的是,不支持通配符在 DN 上。
如果可能的话,我真的会考虑使用 OU=Staff... 和 OU=Vendors... 作为基本 DN 在 2 个查询中执行此操作。
I don't think this is possible with AD. The distinguishedName attribute is the only thing I know of that contains the OU piece on which you're trying to search, so you'd need a wildcard to get results for objects under those OUs. Unfortunately, the wildcard character isn't supported on DNs.
If at all possible, I'd really look at doing this in 2 queries using OU=Staff... and OU=Vendors... as the base DNs.
与 LDAP 专家交谈后,这种方式是不可能的。一项查询无法搜索多个 DC 或 OU。
您的选择是:
After speaking with an LDAP expert, it's not possible this way. One query can't search more than one DC or OU.
Your options are:
tl;dr -- 使用 ou:dn:=语法
对于OP的问题,执行方法是:
原则上,您的情况很棘手,因为 OU 值没有出现在用户的 ldapsearch 输出中 - OU 值是 DN 的一部分。
例如,这里的搜索结果:
没有
ou:
行,因为 OU 属于dn:
行。因此,如果您在搜索中添加ou
,您会看到它是requesting: ou
而不是requesting: ALL
,但没有列出属性:搜索 OU 将为您提供结果,但它们只是 OU 对象,而不是用户本身:
但是,
ldapsearch
允许您使用以下命令提取 DN 的部分内容:ou:dn:=
语法:tl;dr -- Use
ou:dn:=<val>
syntaxFor the OP's question, the way to do it would be:
In principle, your case is tricky because the OU values do not appear in a user's
ldapsearch
output -- OU values are part of the DN.For example, the search result here:
There is no
ou:
line because the OU belongs to thedn:
line. So if you tack on anou
to the search, you'll see that it isrequesting: ou
instead ofrequesting: ALL
, but no attributes get listed:Searching on OU will give you results, but they are only the OU objects, not the users themselves:
However,
ldapsearch
allows you to extract parts of the DN withou:dn:=<val>
syntax: