This topic has not yet been rated - Rate this topic

Principal.FindByIdentity Method (PrincipalContext, IdentityType, String)

Returns a principal object that matches the specified identity type, and value. This version of the FindByIdentity() method determines the format of the identity value.

Namespace:  System.DirectoryServices.AccountManagement
Assembly:  System.DirectoryServices.AccountManagement (in System.DirectoryServices.AccountManagement.dll)
public static Principal FindByIdentity(
	PrincipalContext context,
	IdentityType identityType,
	string identityValue
)

Parameters

context
Type: System.DirectoryServices.AccountManagement.PrincipalContext
The PrincipalContext that specifies the server or domain against which operations are performed.
identityType
Type: System.DirectoryServices.AccountManagement.IdentityType
An IdentityType enumeration value that specifies the format of the identityValue parameter.
identityValue
Type: System.String
The identity of the principal. This parameter can be any format that is contained in the IdentityType enumeration.

Return Value

Type: System.DirectoryServices.AccountManagement.Principal
A Principal object that matches the specified identity value and type or null if no matches are found.
Exception Condition
MultipleMatchesException

Multiple principal objects matching the current object were found.

InvalidEnumArgumentException

The identity type is not a valid IdentityType enumeration value.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Unmanaged memory leak
This call has an unmanaged memory leak because the underlying implemenation uses DirectorySearcher and SearchResultsCollection but does not call dispose on the SearchResultsCollection as the document describes.