【发布时间】:2011-12-15 22:37:11
【问题描述】:
我需要查找具有给定 Guid 的计算机是否存在于给定 OU 中。
为此,我更愿意编写一个Query By Example 来搜索与Guid 匹配的计算机。例如:
PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, container);
ComputerPrincipal computer = new ComputerPrincipal(context);
computer.Guid = guidToMatch;
PrincipalSearcher searcher = new PrincipalSearcher(computer);
// Get the computer if it exists...
当然这不起作用,因为ComputerPrincipal.Guid 字段是只读的。此外,ComputerPrincipal.AdvancedSearchFilter 不包含 Guid 字段。
这可能吗,还是出于某种原因我不想这样做(比如更好的选择)?
【问题讨论】:
标签: c# .net active-directory query-by-example