jasminie

jasminie

  • NA
  • 78
  • 0

C#.net permissions

Aug 30 2011 9:55 AM
Does the following check to see the user has permissions by looking at the active directory for looking at a particualr group?

[STAThread]
static void Main()
{
// Set the thread principal to the current windows identity principal
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

if (!Thread.CurrentPrincipal.IsInRole("SomeRoleToTest"))
{
// Alert the user they need to be granted permissions
}
else
{
// User has rights, allow mains screen to load
Application.Run(new MainWindow());
}
}

Answers (1)