WindowsIdentity.Groups Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the groups the current Windows user belongs to.

Namespace:   System.Security.Principal
Assembly:  mscorlib (in mscorlib.dll)

public IdentityReferenceCollection Groups { get; }

Property Value

Type: System.Security.Principal.IdentityReferenceCollection

An object representing the groups the current Windows user belongs to.

The following code example shows the use of the Groups property to display the identity references for the groups the current user belongs to. This code example is part of a larger example provided for the WindowsIdentity class.

// Display the SIDs for the groups the current user belongs to.
Console.WriteLine("Display the SIDs for the groups the current user belongs to.");
IdentityReferenceCollection irc = windowsIdentity.Groups;
foreach (IdentityReference ir in irc)
    Console.WriteLine(ir.Value);

.NET Framework
Available since 2.0
Return to top
Show: