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