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