尝试在 Active Directory 中搜索有关用户的非空描述(意味着他们有职位),如下面第 4 行所示,但出现无法使用排除项的错误!
关于另一种方法的建议?
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal qbeUser = new UserPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
var example = new UserPrincipal(ctx) { Description != null };
最佳答案
我会尝试这样的事情:
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
UserPrincipal qbeUser = new UserPrincipal(ctx);
qbeUser.Description = "*"; // something, anything - just not empty/NULL
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
......
}
这对你有用吗?基本上,只需在 qbeUser
上定义属性并使用 *
作为通配符表示您希望用户在 Description
属性中有一些东西 - 一些东西, 任何东西 - 不是什么都没有。
关于c# - 在 C# 中排除 Active Directory 的 PrincipalSearcher QueryFilter 中的空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14095832/