Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The SearchRoot property gets or sets the node in the Active Directory hierarchy where the search starts.
public DirectoryEntry SearchRoot {get; set;}
Public Property SearchRoot As DirectoryEntry
Property Value
The DirectoryEntry in the Active Directory hierarchy where the search starts. The default is a null reference (Nothing in Visual Basic).
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 DsGetDcName to find the global catalog.
Get the global catalog's RootDSE and ask for "rootNamingContext".
Use the global catalog like LDAP. For example, "GC://OU=..., DC=..., DC=...".
The following C# code shows how to enumerate the global catalog and pick the first child.
[C#]
DirectoryEntry entry = new DirectoryEntry("GC://forestname");
IEnumerator ie = entry.Children.GetEnumerator(); ie.MoveNext(); entry = (DirectoryEntry)ie.Current; DirectorySearcher search = new DirectorySearcher(entry);
Requirements
| Client | Requires Windows XP Home Edition, Windows XP Professional, Windows Me, or Windows 98. |
| Server | Requires Windows Server 2003, Windows 2000, or Windows NT 4.0. |
| Namespace | Defined in System.DirectoryServices. |
| Assembly | Requires System.DirectoryServices (in System.DirectoryServices.dll). |
| .NET Framework | Requires .NET Framework 1.0. |
See Also
DirectoryEntry, DirectorySearcher, DirectorySearcher Constructors, DirectorySearcher Methods, DirectorySearcher Properties, System.DirectoryServices Namespace, DirectorySearcher Members (Visual J# Syntax), Managed Extensions for C++ Programming