1
2
3
4
5
6
7
8
using System.Security.Principal;
 
bool IsAdmin()
{
   WindowsIdentity  identity = WindowsIdentity.GetCurrent();
   WindowsPrincipal principal =  new WindowsPrincipal (identity);
   return principal.IsInRole (WindowsBuiltInRole.Administrator);
}