Uređivanje

Dijeli putem


PrincipalPermission.IsSubsetOf(IPermission) Method

Definition

Determines whether the current permission is a subset of the specified permission.

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

Parameters

target
IPermission

A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission.

Returns

true if the current permission is a subset of the specified permission; otherwise, false.

Implements

Exceptions

The target parameter is an object that is not of the same type as the current permission.

Examples

The following example defines instances of PrincipalPermission corresponding to three distinct users. Two additional instances are then created as groups of users. pp1 represents Bob and Louise, pp2 represents Bob, Louise, and 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)

With the preceding declarations, pp1.IsSubsetOf(pp2) returns true, and pp2.IsSubsetOf(pp1) returns false.

Remarks

The current permission is a subset of the specified permission if all demands that succeed for the current permission also succeed for the specified permission.

Applies to