简体   繁体   English

使用模式匹配的LDAP查询

[英]LDAP Queries using Pattern Matching

Is it possible with LDAP queries to filter on patterns similar to Regular Expressions? LDAP查询是否可以过滤类似于正则表达式的模式? For example, to find all computer objects with names that match "ABC-nnnnnn" where "n" is a numeric digit and only those with 6-digits? 例如,要查找名称与“ ABC-nnnnnn”匹配的所有计算机对象,其中“ n”是数字,而只有那些6位?

To my knowledge LDAP only supports wildcards, like: 据我所知,LDAP仅支持通配符,例如:

(CN=ABC-*)

That'll grab anything that starts with ABC- . 那会抢到任何以ABC-开头的东西。 You would probably have to further filter the results using something else like PowerShell, or programming language of your choice. 您可能必须使用PowerShell等其他语言或您选择的编程语言进一步过滤结果。

除了通配符建议外,没有其他功能。

LDAP search filters do not support the concept of pattern matching, but they do support the concept of ordering . LDAP搜索过滤器不支持模式匹配的概念,但确实支持排序的概念。 LDAP clients should consult the schema programmatically to determine which ordering rules are used for attributes, and if an appropriate ordering rule is supported, a combination of greaterOrEqual and lessOrEqual filter components in a compound filter might work. LDAP客户端应以编程方式咨询架构,以确定哪些排序规则用于属性,并且如果支持适当的排序规则,则在复合过滤器中组合使用greaterOrEquallessOrEqual过滤器组件可能有效。 Whether or not the results are as expected depends completely on the ordering rules. 结果是否符合预期完全取决于订购规则。

For example: 例如:

ldapsearch -h hostname -p port \
  -b basedn -s scope \
  `(&(cn>=abc-000000)(cn<=abc-999999))` attribute_list

As above, whether this returns the expected results depends on the ordering rules. 如上所述,是否返回预期结果取决于订购规则。 Consult your friendly neightborhood LDAP admin for help with ordering rules and schema. 请咨询您友好的Nightborhood LDAP管理员,以获取有关订购规则和架构的帮助。

see also 也可以看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM