Home
Manage Your Code
Snippet: Check if user have Administrator rights (C#)
Title: Check if user have Administrator rights Language: C#
Description: This code check if current user have administrator rights on machine Views: 689
Author: Michele Pattaro Date Added: 4/10/2009
Copy Code  
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}