在构建过滤器以查找具有特定值的对象时,Principal Searcher 似乎做得很好。没有怎么办?例如,我如何构建过滤器以排除名称中带有“Joe”的每个人。下面的代码不起作用。
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal qbeUser = new UserPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
//this is the problem line. How to format to exclude values with Joe?
qbeUser.Name != "*Joe*";
srch.QueryFilter = qbeUser;
foreach (var found in srch.FindAll())
{ do something to non Joe users... }
……