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成功,则 为目标的子集。 也就是说,目标至少包含子集中包含的权限。

适用于