LDAP 与 objectCategory 查询问题
我想创建 LDAP 查询来按名称、位置和型号过滤打印机
deSearch.Filter = String.Format("(&(&(&(&(objectCategory=printQueue)(printername={0}))(location={1}))(driverName={2})))", queueName, location, modelNumber);
我创建了此查询,但它运行不正确
- 第一个问题是如果其中一个条件为空或 null,则按所有搜索条件一起搜索
- ,我将其设置为 *得到所有结果。它正确吗?
欢迎所有想法
I want to create LDAP query to filter printers by name and location and model
deSearch.Filter = String.Format("(&(&(&(&(objectCategory=printQueue)(printername={0}))(location={1}))(driverName={2})))", queueName, location, modelNumber);
I create this but it didn't run correctly
- The first problem is to search by all search criteria together
- if one of criteria is empty or null ,I set it by * to get all results .Is it correct ?
All ideas are welcomed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需要一个 &操作员。它们是 LDAP 过滤器表达式中的 n 元运算符,而不是二进制运算符:
(RFC 2254 将 &(或 |)后面的内容定义为一组过滤器,而不是恰好两个过滤器。这是我能看到的唯一好的理由为什么他们选择那个可怕的前缀符号。)
我个人也会在这样的查询中提供“printQueue”作为参数。
'*' 将匹配任何属性值,但它要求该属性实际存在,即 objectClass具有这样的属性。
You only need one & operator. They are n-ary, not binary, operators in LDAP filter expressions:
(RFC 2254 defines what follows the & (or |) as a SET OF Filter, not as exactly two filters. This is about the only good reason I can see why they chose that ghastly prefix notation.)
I would personally supply 'printQueue' as an argument as well in a query like this.
'*' will match any attribute value, but it requires the attribute to be actually present, i.e. for the objectClass to have such an attribute.
根据 EJP 回复,我在这里创建了代码
Accoroding to EJP reply I created the code for that here