PrincipalSearcher.FindOne Method ()

 

Returns a principal search result that contains the first principal object found that matches the principal specified in the QueryFilter property.

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

[SecurityCriticalAttribute]
public Principal FindOne()

Return Value

Type: System.DirectoryServices.AccountManagement.Principal

A Principal object that contains the principal object that matches the query filter or null if no results are found.

Exception Condition
InvalidOperationException

The QueryFilter contains referential properties. For more information, see the Query by Example overview topic.

The QueryFilter is a persisted principal.

ArgumentException

A QueryFilter must first be assigned to the principal searcher before the query can be performed.

If there is exactly one match of the object specified in the QueryFilter, this method returns that object. If there are multiple matches of the QueryFilter object, this method arbitrarily returns one of the matching principals.

The Principal object returned from this method matches the type of object contained in the QueryFilter property. The search is conducted in the context specified in the Context property. For more information, see the Query by Example overview topic.

.NET Framework
Available since 3.5

System.DirectoryServices.AccountManagement
PrincipalSearcher Class
Query by Example
System.DirectoryServices.AccountManagement Namespace Overview

Return to top
Show: