using System.Security.Principal;
public static class Global
{
public static bool UserIsInRole(string role)
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(role);
}
public static bool UserIsInRole(WindowsBuiltInRole role)
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(role);
}
}
Usage:
bool isAdmin = Global.UserIsInRole(WindowsBuiltInRole.Administrator);
or...
bool hasRole = Global.UserIsInRole("Developer");
Since we can't actually see your code or possible know everyplace you'd want to restrict access by role, you're going to have to determine where and how to implement this. My personal preference is to control access by implementing the role check in menus or at buttons in forms, enabling items that the user can use, and disabling the ones they can't.