find out whether current user is administrator
Published: 14. October 2011 | Updated: 26. October 2011License: Microsoft Public License (MS-PL)
Categories: Windows » Authorization
Tags: Authorization C# Windows
Import namespace
using System.Security.Principal;
Code
var identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); bool isAdministrator = principal.IsInRole(WindowsBuiltInRole.Administrator);
| Send us feedback about this snippet » |





