DirectorySearcher.SearchRoot Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value indicating the node in the Active Directory Domain Services hierarchy where the search starts.
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
Property Value
The DirectoryEntry object in the Active Directory Domain Services hierarchy where the search starts. The default is a null reference (Nothing
in Visual Basic).
- Attributes
Remarks
If SearchRoot is a null reference (Nothing
in Visual Basic), the search root is set to the root of the domain that your server is currently using.
There are several ways to search in the global catalog:
Enumerate the global catalog and pick the first child.
Specify the server name. Use the DsGetDcName function to find the global catalog. For more information on the DsGetDcName function, see the DsGetDcName.
Get the RootDSE of the global catalog and ask for "rootNamingContext".
Use the global catalog, specifying a search path as if using LDAP. For example, "GC://OU=..., DC=..., DC=...".
The following C# code shows how to enumerate the global catalog and pick the first child.
DirectoryEntry entry = new DirectoryEntry("GC://forestname"); IEnumerator ie = entry.Children.GetEnumerator(); ie.MoveNext(); entry = (DirectoryEntry)ie.Current; DirectorySearcher search = new DirectorySearcher(entry);
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應