C#LDAP查询的持续性

时间:2019-04-19 16:18:16

标签: c# ldap

尝试通过C#查询DC时,我收到LDAP格式错误的查询通知。

我正在尝试获取禁用的Windows帐户的列表。

DirectoryEntry entry = new DirectoryEntry("LDAP://dc-7f-01.uidc.ccb");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803: = 2 )");

2 个答案:

答案 0 :(得分:0)

您忘记了将条件包装在and中。您的过滤器字符串应为:

"(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))"

您可以了解有关过滤器语法here的更多信息。

答案 1 :(得分:0)

这成功了...  mySearcher.Filter =“(&(objectCategory = person)(objectClass = user)(userAccountControl:1.2.840.113556.1.4.803:= 2))”;

相关问题