DirectorySearcher.SearchRoot Property
Gets or sets the node in the Active Directory hierarchy where the search starts.
[Visual Basic] Public Property SearchRoot As DirectoryEntry [C#] public DirectoryEntry SearchRoot {get; set;} [C++] public: __property DirectoryEntry* get_SearchRoot(); public: __property void set_SearchRoot(DirectoryEntry*); [JScript] public function get SearchRoot() : DirectoryEntry; public function set SearchRoot(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.
DirectoryEntry entry = new DirectoryEntry("GC:");
IEnumerator ie = entry.Children.GetEnumerator();
ie.MoveNext();
entry = (DirectoryEntry)ie.Current;
DirectorySearcher search = new DirectorySearcher(entry); Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
DirectorySearcher Class | DirectorySearcher Members | System.DirectoryServices Namespace | DirectoryEntry