Performs queries against Active Directory.
For a list of all members of this type, see DirectorySearcher Members.
[Visual Basic] Public Class DirectorySearcher Inherits Component [C#] public class DirectorySearcher : Component [C++] public __gc class DirectorySearcher : public Component [JScript] public class DirectorySearcher extends Component
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Use a DirectorySearcher to search and perform queries against an Active Directory hierarchy using the Lightweight Directory Access Protocol (LDAP). LDAP is the only system-supplied Active Directory Service Interfaces (ADSI) provider that supports directory searching. An administrator can make, alter, and delete objects found in the hierarchy. For more information, see Introduction to Active Directory Objects in Visual Studio.NET.
When you create an instance of DirectorySearcher, you specify through the SearchRoot property the root you want to retrieve, and an optional list of properties to retrieve. You can also set properties to determine:
- Whether to cache the search results on the local computer. Set the CacheResults property to true to store directory information on the local computer. Updates are made to this local cache and committed to Active Directory only when the DirectoryEntry.CommitChanges method is called.
- How long to spend on the search. Use the ServerTimeLimit property to specify the length of time to search.
- Whether to only retrieve attribute names. Set the PropertyNamesOnly property to true to retrieve only the names of attributes to which values have been assigned.
- Whether to perform a paged search. Set the PageSize property specify the maximum number of objects returned in a paged search. If you do not want to perform a paged search, set the PageSize property to its default of zero.
- The maximum number of entries to return. Set the SizeLimit property to specify the maximum number of entries to return. Setting the SizeLimit property to its default of zero sets it to the server-determined default of 1000 entries.
Note If the maximum number of returned entries and time limits exceed limitations set on the server, the server settings override the component settings.
For a list of initial property values for an instance of DirectorySearcher, see the DirectorySearcher constructor.
Note It is assumed that you have a general understanding of Active Directory before using this class. For more information, see the System.DirectoryServices namespace overview.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Directoryservices (in System.Directoryservices.dll)
DirectorySearcher Members | System.DirectoryServices Namespace | DirectoryEntry | DirectoryEntries | PropertyCollection | PropertyValueCollection | ReferralChasingOption | SearchResultCollection | SearchResult | ResultPropertyCollection | ResultPropertyValueCollection | SearchScope | SortDirection | SortOption