Export (0) Print
Expand All

Principal.GetGroups Method (PrincipalContext)

Returns a collection of group objects that the principal is a member of and that exist in the store provided by the specified context parameter.

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

'Declaration
Public Function GetGroups ( _
	contextToQuery As PrincipalContext _
) As PrincipalSearchResult(Of Principal)

Parameters

contextToQuery
Type: System.DirectoryServices.AccountManagement.PrincipalContext

The PrincipalContext object that specifies the context against which the query is performed.

When the context is located in another domain, the query is performed against the principal objects' representation in the specified context.

Return Value

Type: System.DirectoryServices.AccountManagement.PrincipalSearchResult(Of Principal)
A collection of GroupPrincipal objects that specify the groups of which the current principal is a member.

This method returns only the groups of which the principal is directly a member; no recursive searches are performed. Recursive search results are available for user principal objects. For more information, see the GetAuthorizationGroups method.

The groups that are returned by this method may include groups from a different scope and store than the principal. For example, if the principal is an AD DS object that has a DN of "CN=SpecialGroups,DC=Fabrikam,DC=com, the returned set can contain groups that belong to the "CN=NormalGroups,DC=Fabrikam,DC=com.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft