共用方式為


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

適用於