Export (0) Print
Expand All

DirectorySearcher.SearchRoot Property

Gets or sets a value indicating the node in the Active Directory Domain Services hierarchy where the search starts.

Namespace:  System.DirectoryServices
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

[DSDescriptionAttribute("DSSearchRoot")]
public DirectoryEntry SearchRoot { get; set; }

Property Value

Type: System.DirectoryServices.DirectoryEntry
The DirectoryEntry object in the Active Directory Domain Services hierarchy where the search starts. The default is a null reference (Nothing in Visual Basic).

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 topic "DsGetDcName" in the MSDN Library at http://msdn.microsoft.com/library.

  • 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);
    

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft