SetPrincipalPolicy : AppDomain « Development Class « C# / C Sharp






SetPrincipalPolicy

 
using System;
using System.Security;
using System.Security.Principal;
using System.Security.Permissions;

class Program {
    static void Main(string[] args) {
        AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
        try {
            ShowMessage();
        } catch (SecurityException exception) {
            Console.WriteLine(exception.Message);
        }
    }

    [PrincipalPermissionAttribute(SecurityAction.Demand,Role = "BUILTIN\\Users")]
    static void ShowMessage() {
        Console.WriteLine("The current principal is logged in locally ");
        Console.WriteLine("(they are a member of the local Users group)");
    }
}

 








Related examples in the same category

1.AppDomain.CreateDomain
2.SetData, GetData
3.Configure the AppDomainSetup
4.FriendlyName
5.creates three instances of the same type. A local and two remote proxies to object instances are constructed:
6.OnUnhandledException method is added to the AppDomain.UnhandledException event