using System;
using System.Security;
using System.Security.Principal;
using System.Security.Permissions;
class Class1 {
static void Main(string[] args) {
//AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity wi = WindowsIdentity.GetCurrent();
PrincipalPermission PrincipalPerm = new PrincipalPermission(wi.Name, "Administrator");
try {
PrincipalPerm.Demand();
Console.WriteLine("Code demand for an administrator succeeded.");
} catch (SecurityException e) {
Console.WriteLine("Demand for administrator failed!");
Console.WriteLine(e.Message);
}
}
}