ComputerPrincipal.FindByIdentity Method (PrincipalContext, IdentityType, String)


Returns a computer 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 ComputerPrincipal FindByIdentity(
	PrincipalContext context,
	IdentityType identityType,
	string identityValue


Type: System.DirectoryServices.AccountManagement.PrincipalContext

The T:System.DirectoryService.AccountManagement.PrincipalContext that specifies the server or domain against which operations are performed.

Type: System.DirectoryServices.AccountManagement.IdentityType

A IdentityType enumeration value that specifies the format of the identityValue parameter.

Type: System.String

The identity of the computer. This parameter can be any format that is contained in the T:System.DirectoryService.AccountManagement.IdentityType enumeration.

Return Value

Type: System.DirectoryServices.AccountManagement.ComputerPrincipal

A ComputerPrincipal object that matches the specified identity value and type, or null if no matches are found.

Exception Condition

Multiple computer principal objects matching the current computer object were found.


The identity value is not a valid IdentityType enumeration value.

.NET Framework
Available since 3.5
Return to top