WindowsIdentity.Groups 属性

定义

获取当前 Windows 用户所属的组。

public:
 property System::Security::Principal::IdentityReferenceCollection ^ Groups { System::Security::Principal::IdentityReferenceCollection ^ get(); };
public System.Security.Principal.IdentityReferenceCollection? Groups { get; }
public System.Security.Principal.IdentityReferenceCollection Groups { get; }
member this.Groups : System.Security.Principal.IdentityReferenceCollection
Public ReadOnly Property Groups As IdentityReferenceCollection

属性值

一个对象,它表示当前 Windows 用户所属的组。

示例

下面的代码示例演示如何使用 Groups 属性来显示当前用户所属组的标识引用。 此代码示例是为 WindowsIdentity 类提供的一个更大示例的一部分。

// 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);
' Display the SIDs for the groups the current user belongs to.
Console.WriteLine("Display the SIDs for the groups the current user belongs to.")
Dim irc As IdentityReferenceCollection
Dim ir As IdentityReference
irc = windowsIdentity.Groups
For Each ir In irc
    Console.WriteLine(ir.Value)
Next

适用于