共用方式為


PermissionSet.IsSubsetOf(PermissionSet) 方法

定義

判斷目前的 PermissionSet 是否為指定 PermissionSet 的子集。

public:
 bool IsSubsetOf(System::Security::PermissionSet ^ target);
public:
 virtual bool IsSubsetOf(System::Security::PermissionSet ^ target);
public bool IsSubsetOf (System.Security.PermissionSet? target);
public virtual bool IsSubsetOf (System.Security.PermissionSet target);
public bool IsSubsetOf (System.Security.PermissionSet target);
member this.IsSubsetOf : System.Security.PermissionSet -> bool
abstract member IsSubsetOf : System.Security.PermissionSet -> bool
override this.IsSubsetOf : System.Security.PermissionSet -> bool
Public Function IsSubsetOf (target As PermissionSet) As Boolean
Public Overridable Function IsSubsetOf (target As PermissionSet) As Boolean

參數

target
PermissionSet

要測試子集關聯性的權限集。 這必須是 PermissionSetNamedPermissionSet

傳回

如果目前的 PermissionSettarget 參數的子集則為 true否則為 false

範例

下列程式代碼範例顯示 方法的使用 IsSubsetOf 方式。 此程式代碼範例是針對 類別提供的較大範例的 PermissionSet 一部分。

// Create a second permission set and compare it to the first permission set.
ps2->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Read,"USERNAME" ) );
ps2->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Write,"COMPUTERNAME" ) );
IEnumerator^ list =  ps1->GetEnumerator();
Console::WriteLine("Permissions in first permission set:");
      while (list->MoveNext())
          Console::WriteLine(list->Current->ToString());
Console::WriteLine( "Second permission IsSubsetOf first permission = {0}", ps2->IsSubsetOf( ps1 ) );
// Create a second permission set and compare it to the first permission set.
ps2.AddPermission(
    new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"));
ps2.AddPermission(
    new EnvironmentPermission(EnvironmentPermissionAccess.Write, "COMPUTERNAME"));
IEnumerator list =  ps1.GetEnumerator();
Console.WriteLine("Permissions in first permission set:");
while (list.MoveNext())
    Console.WriteLine(list.Current.ToString());
Console.WriteLine("Second permission IsSubsetOf first permission = " + ps2.IsSubsetOf(ps1));
' Create a second permission set and compare it to the first permission set.
ps2.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"))
ps2.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Write, "COMPUTERNAME"))
Console.WriteLine("Permissions in first permission set:")
Dim list As IEnumerator = ps1.GetEnumerator()
While list.MoveNext()
    Console.WriteLine(list.Current.ToString())
End While
Console.WriteLine("Second permission IsSubsetOf first permission = " & ps2.IsSubsetOf(ps1))

備註

PermissionSet如果目標的所有要求都成功PermissionSet,則為目標的PermissionSet子集。 也就是說,目標至少包含子集中包含的許可權。

適用於