语言

DirectorySearcher.SearchRoot 属性

定义

获取或设置一个值,该值指示搜索开始的Active Directory 域服务层次结构中的节点。

public:
 property System::DirectoryServices::DirectoryEntry ^ SearchRoot { System::DirectoryServices::DirectoryEntry ^ get(); void set(System::DirectoryServices::DirectoryEntry ^ value); };
public System.DirectoryServices.DirectoryEntry? SearchRoot { get; set; }
[System.DirectoryServices.DSDescription("DSSearchRoot")]
public System.DirectoryServices.DirectoryEntry SearchRoot { get; set; }
public System.DirectoryServices.DirectoryEntry SearchRoot { get; set; }
member this.SearchRoot : System.DirectoryServices.DirectoryEntry with get, set
[<System.DirectoryServices.DSDescription("DSSearchRoot")>]
member this.SearchRoot : System.DirectoryServices.DirectoryEntry with get, set
Public Property SearchRoot As DirectoryEntry

属性值

搜索开始的Active Directory 域服务层次结构中的 DirectoryEntry 对象。 默认值为 null 引用(Nothing 在 Visual Basic 中)。

特性

注解

如果 SearchRoot 是空引用(Nothing在 Visual Basic),则搜索根设置为服务器当前使用的域的根目录。

可通过多种方式在全局目录中搜索:

  • 枚举全局目录并选取第一个子目录。

  • 指定服务器名称。 使用 DsGetDcName 函数查找全局目录。 有关 DsGetDcName 函数的详细信息,请参阅 DsGetDcName。

  • 获取全局目录的 RootDSE 并请求“rootNamingContext”。

  • 使用全局目录,指定搜索路径,就像使用 LDAP 一样。 例如,“GC://OU=...,DC=...,DC=...”。

  • 以下 C# 代码演示如何枚举全局目录并选取第一个子目录。

    DirectoryEntry entry = new DirectoryEntry("GC://forestname");
    IEnumerator ie = entry.Children.GetEnumerator();
    ie.MoveNext();
    entry = (DirectoryEntry)ie.Current;
    DirectorySearcher search = new DirectorySearcher(entry);
    

适用于