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.
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.PrincipalA 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.
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.
- 8/25/2008
- Gary Caldwell MSFT
- 8/30/2008
- Thomas Lee