共用方式為


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 和 Bobe, pp2 代表 Bob、則代表 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回 。

備註

如果所有要求目前許可權都成功,則目前許可權也是指定許可權的子集。

適用於