【问题标题】:Is it possible to search for a Guid in a "Query By Example"?是否可以在“示例查询”中搜索 Guid?
【发布时间】: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


    【解决方案1】:

    看起来处理这个问题的方法是使用FindByIdentity()

    PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, container);
    ComputerPrincipal computer = ComputerPrincipal.FindByIdentity(context, guidToMatch);
    

    【讨论】:

      【解决方案2】:

      另一种处理方法是对表单进行基本搜索。这基本上允许您通过 objectGUID 搜索对象并取回匹配项,无论是计算机还是其他类型的对象。然后,您可以检查该对象,看看它是否是您的想法......

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-02
        • 1970-01-01
        • 2014-05-05
        • 2014-01-07
        • 1970-01-01
        相关资源
        最近更新 更多