Use a DirectorySearcher object to search and perform queries against an Active Directory Domain Services hierarchy using 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 that are found in the hierarchy. For more information, see Using System.DirectoryServices.

When you create an instance of DirectorySearcher, you specify the root you want to retrieve, and an optional list of properties to retrieve. The SearchRoot property enables you to set additional properties to do the following tasks:

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 Domain Services only when the DirectoryEntry.CommitChanges method is called.

Retrieve attribute names only. Set the PropertyNamesOnly property to true to retrieve only the names of attributes to which values have been assigned.

Perform a paged search. Set the PageSize property to specify the maximum number of objects that are returned in a paged search. If you do not want to perform a paged search, set the PageSize property to its default of zero.

Specify the maximum number of entries to return, using the SizeLimit property. If you set the SizeLimit property to its default of zero, the server-determined default is 1000 entries.

Note:

If the maximum number of returned entries and time limits exceed the limitations that are set on the server, the server settings override the component settings.

For a list of initial property values for an instance of the DirectorySearcher class, see the DirectorySearcher constructor.

Note:

It is assumed that you have a general understanding of Active Directory Domain Services before using this class. For more information, see the System.DirectoryServices overview.