Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
PrincipalSearcher Class

PrincipalSearcher Class

Encapsulates the methods and search patterns used to execute a query against the underlying principal store.


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

[DirectoryServicesPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
[DirectoryServicesPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
public class PrincipalSearcher : IDisposable

The PrincipalSearcher type exposes the following members.

Public methodPrincipalSearcher()Initializes a new instance of the PrincipalSearcher class. The QueryFilter property must be set before the Principal searcher object can be used to perform a search.
Public methodPrincipalSearcher(Principal)Initializes a new instance of the PrincipalSearcher class with the specified query filter.

Public propertyContextGets that principal context that is used to perform the query. The context specifies the server or domain against which search operations are performed.
Public propertyQueryFilterGets or sets the query filter that is used to locate matching principals.

Public methodDisposeDisposes the current instance of the PrincipalSearcher object.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindAllReturns a principal search result that contains a collection of all the principal objects that match the principal specified in the query filter property.
Public methodFindOneReturns a principal search result that contains the first principal object found that matches the principal specified in the QueryFilter property.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUnderlyingSearcherReturns the underlying search object that is used by the Account Management API to perform the search.
Public methodGetUnderlyingSearcherTypeReturns the type of the object returned from the GetUnderlyingSearcher method.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The default page size of 256 KB is used when the PrincipalSearcher class performs a query for domain principals. The application may override the default value by setting the PageSize property in the underlying DirectorySearcher object that is returned from the GetUnderlyingSearcher method.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft