Union two PrincipalPermissions : PrincipalPermission « Security « C# / C Sharp






Union two PrincipalPermissions

 

using System;
using System.Security.Permissions;

class MainClass {


    public static void Method2() {
        PrincipalPermission perm1 = new PrincipalPermission(null, @"MACHINE\Managers");

        PrincipalPermission perm2 = new PrincipalPermission(null, @"MACHINE\Developers");

        perm1.Union(perm2).Demand();
    }

    public static void Method3() {
        PrincipalPermission perm = new PrincipalPermission(@"MACHINE\Tester", @"MACHINE\Managers");
        perm.Demand();
    }
    [PrincipalPermission(SecurityAction.Demand, Name = @"MACHINE\Tester")]
    public static void Method4() {
    }

    [PrincipalPermission(SecurityAction.Demand, Role = @"MACHINE\Managers")]
    [PrincipalPermission(SecurityAction.Demand, Role = @"MACHINE\Developers")]
    public static void Method5() {
        // Method implementation. . .
    }
    [PrincipalPermission(SecurityAction.Demand, Name = @"MACHINE\Tester",
        Role = @"MACHINE\Managers")]
    public static void Method6() {
        // Method implementation. . .
    }
}

 








Related examples in the same category

1.new PrincipalPermission(null, @"MACHINE\Managers")
2.Demand PrincipalPermission