using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Exam2
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
try
{
ShowMessage();
}
catch (SecurityException exception)
{
Console.WriteLine("Security exception caught ({0})", exception.Message);
Console.WriteLine("The current principal must be in the local"
+ "Users group");
}
Console.Read();
}
//[PrincipalPermission(SecurityAction.Demand, Role = "BUILTIN\Users")]
[PrincipalPermission(SecurityAction.Demand, Role = "BUILTIN\Guest")]
static void ShowMessage()
{
Console.WriteLine("The current principal is logged in locally ");
Console.WriteLine("(member of the local Users group)");
}
}
}