AppDomain.SetPrincipalPolicy : AppDomain « System « C# / C Sharp by API






AppDomain.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.AppDomain.CreateInstance
3.AppDomain.CreateInstanceAndUnwrap
4.AppDomain.CreateInstanceFromAndUnwrap
5.AppDomain.CurrentDomain.FriendlyName
6.AppDomain.CurrentDomain
7.AppDomain.DefineDynamicAssembly
8.AppDomain.DoCallBack
9.AppDomain.DomainUnload
10.AppDomain.FriendlyName
11.AppDomain.GetAssemblies
12.AppDomain.GetData
13.AppDomain.OnUnhandledException
14.AppDomain.ProcessExit
15.AppDomain.SetData
16.AppDomain.Unload