PrincipalPermission.IsSubsetOf(IPermission) 方法

定义

确定当前权限是否为指定权限的子集。

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

参数

target
IPermission

将要测试子集关系的权限。 此权限必须与当前权限属于同一类型。

返回

如果当前权限是指定权限的子集,则为 true;否则为 false

实现

例外

target 参数是一个对象,并且与当前权限不属于同一类型。

示例

以下示例定义对应于三个不同用户的 实例 PrincipalPermission 。 然后,将另外两个实例创建为用户组。 pp1 代表 Bob 和 Louise, pp2 代表 Bob、Louise 和 Greg。

//Define users and roles.
PrincipalPermission^ ppBob = gcnew PrincipalPermission( "Bob", "Manager" );
PrincipalPermission^ ppLouise = gcnew PrincipalPermission( "Louise", "Supervisor" );
PrincipalPermission^ ppGreg = gcnew PrincipalPermission( "Greg", "Employee" );

//Define groups of users.
PrincipalPermission^ pp1 = (PrincipalPermission^) (ppBob->Union( ppLouise ));
PrincipalPermission^ pp2 = (PrincipalPermission^) (ppGreg->Union( pp1 ));
//Define users and roles.
PrincipalPermission ppBob = new PrincipalPermission("Bob", "Manager");
PrincipalPermission ppLouise = new PrincipalPermission("Louise", "Supervisor");
PrincipalPermission ppGreg = new PrincipalPermission("Greg", "Employee");

//Define groups of users.
PrincipalPermission pp1 = (PrincipalPermission)ppBob.Union(ppLouise);
PrincipalPermission pp2 = (PrincipalPermission)ppGreg.Union(pp1);
'Define users and roles.
Dim ppBob As New PrincipalPermission("Bob", "Manager")
Dim ppLouise As New PrincipalPermission("Louise", "Supervisor")
Dim ppGreg As New PrincipalPermission("Greg", "Employee")
       
'Define groups of users.
Dim pp1 As PrincipalPermission = _
   CType(ppBob.Union(ppLouise), PrincipalPermission)
Dim pp2 As PrincipalPermission = _
   CType(ppGreg.Union(pp1), PrincipalPermission)

使用上述声明, pp1.IsSubsetOf(pp2) 返回 true, 返回 pp2.IsSubsetOf(pp1)false

注解

如果当前权限的所有成功要求也针对指定权限成功,则当前权限是指定权限的子集。

适用于