DataProtectionPermission.IsSubsetOf(IPermission) Méthode

Définition

Détermine si l’autorisation actuelle est un sous-ensemble de l’autorisation spécifiée.

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

Paramètres

target
IPermission

Autorisation à tester pour la relation de sous-ensemble. Cette autorisation doit être du même type que l’autorisation actuelle.

Retours

true si l’autorisation actuelle est un sous-ensemble de l’autorisation spécifiée ; sinon, false.

Exceptions

target n’est pas null et ne spécifie pas d’autorisation du même type que l’autorisation actuelle.

Exemples

L’exemple de code suivant montre l’utilisation de la IsSubsetOf méthode . Cet exemple de code fait partie d’un exemple plus grand fourni pour la DataProtectionPermission classe .

Notes

L’exemple de code est destiné à montrer le comportement de la méthode, et non à illustrer son utilisation. En général, les méthodes des classes d’autorisation sont utilisées par l’infrastructure de sécurité ; ils ne sont généralement pas utilisés dans les applications.

bool rc = sp2->IsSubsetOf( sp3 );
Console::WriteLine( "Is the permission with all flags set (AllFlags) "
"a subset of \n \tthe permission with an Unrestricted "
"permission state? {0}", (rc ? (String^)"Yes" : "No") );
rc = sp1->IsSubsetOf( sp2 );
Console::WriteLine( "Is the permission with ProtectData access a "
"subset of the permission with \n"
"\tAllFlags set? {0}", (rc ? (String^)"Yes" : "No") );
bool rc = sp2.IsSubsetOf(sp3);
Console.WriteLine("Is the permission with all flags set (AllFlags) " +
    "a subset of \n \tthe permission with an Unrestricted " +
    "permission state? " + (rc ? "Yes" : "No"));
rc = sp1.IsSubsetOf(sp2);
Console.WriteLine("Is the permission with ProtectData access a " +
    "subset of the permission with \n" + "\tAllFlags set? " +
    (rc ? "Yes" : "No"));
Dim rc As Boolean = sp2.IsSubsetOf(sp3)
Console.WriteLine("Is the permission with all flags set (AllFlags) " + "a subset of " + vbLf + " " + vbTab + "the permission with an Unrestricted " + "permission state? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
rc = sp1.IsSubsetOf(sp2)
Console.WriteLine("Is the permission with ProtectData access a " + "subset of the permission with " + vbLf + vbTab + "AllFlags set? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements

Remarques

L’autorisation actuelle est un sous-ensemble de l’autorisation spécifiée si l’autorisation actuelle spécifie un ensemble d’opérations qui est entièrement contenu dans l’autorisation spécifiée. Par exemple, une autorisation d’accès ProtectData est un sous-ensemble d’une autorisation d’accès AllFlags .

S’applique à