IsMemberOf Method (PrincipalContext, IdentityType, String)

Principal.IsMemberOf Method (PrincipalContext, IdentityType, String)

.NET Framework (current version)

Returns a Boolean value that specifies whether the principal is a member of the group specified by identity type and value.

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

Public Function IsMemberOf (
	context As PrincipalContext,
	identityType As IdentityType,
	identityValue As String
) As Boolean


Type: System.DirectoryServices.AccountManagement.PrincipalContext

The PrincipalContext that specifies the server or domain against which operations are performed.

Type: System.DirectoryServices.AccountManagement.IdentityType

A IdentityType enumeration value that specifies the type of the identity value.

Type: System.String

The identity of the group.

Return Value

Type: System.Boolean

true if the principal is a member of the specified group; otherwise false.

Exception Condition

The identity type or value does not correspond to a GroupPrincipal.


More than one matching GroupPrincipal was found.

If the current principal is an AD DS principal, the returned groups include the principal's primary group, as indicated by the primary group ID attribute on the AD DS object.

.NET Framework
Available since 3.5
Return to top
© 2016 Microsoft