Export (0) Print
Expand All

PrincipalPermission.IsSubsetOf Method

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

Namespace:  System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

public bool IsSubsetOf(
	IPermission target
)

Parameters

target
Type: System.Security.IPermission

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

Return Value

Type: System.Boolean
true if the current permission is a subset of the specified permission; otherwise, false.

Implements

IPermission.IsSubsetOf(IPermission)

ExceptionCondition
ArgumentException

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

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.

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 = 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);

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft