VB.NET的LDAP查询问题 [英] LDAP query problem with VB.NET
问题描述
我正在运行一小段代码,用于填充LDAP查询的下拉列表。它检查给定名称或姓氏是否以输入的字母开头。例如
S会返回sarah或smith
SM只会返回史密斯
但不是如果职位名称=离开者
代码工作正常,除非我想在查询中添加不是
这个有用: -
I'm running a small piece of code that populates a drop down from an LDAP query. It checks if the givenname OR the surname start with the letter that is input. e.g.
S would return sarah or smith
SM would return just smith
but not if the Job title = leaver
The code works fine, except if I want to add a not to the query
This works :-
osearcher.Filter = "(|(givenname=" & Label1.Text.ToString & "*)(sn=" & Label1.Text.ToString & "*))"
但这不是: -
But this doesn't :-
osearcher.Filter = "(|(givenname=" & Label1.Text.ToString & "*)(sn=" & Label1.Text.ToString & "*))(!(title=leaver))"
我收到目录服务不可用错误
有什么想法吗?我只使用LDAP作业标题字段来排除某个OU
我尝试了什么:
我将查询剪切并粘贴到活动目录自定义搜索中并且工作正常
(例如,结果看起来像这样
I get a "The Directory Service is unavailable" error
Any ideas ? I'm only using the LDAP Job Title field to exclude a certain OU
What I have tried:
I cut and pasted the query into an active directory custom search and it worked fine
(e.g. the result looks like this
(|(givenName=a*)(sn=a*))(!(title=leaver))
推荐答案
就像我提交的那样我修好了它。
好像用vb.net你需要用&符号开始查询,例如
Ugh just as I submitted I fixed it :)
Seems like with vb.net you need to start the query with an ampersand e.g.
osearcher.Filter = "(&(|(givenname=" & Label1.Text.ToString & "*)(sn=" & Label1.Text.ToString & "*))(!(title=leaver)))"
这篇关于VB.NET的LDAP查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!