SetPrincipalPolicy : AppDomain : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » 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)");
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» AppDomain