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