Friday, July 31, 2009

Check the login user's windowsprincipal(For example whether role is administrator)

using System;
using System.Security.Principal;


WindowsIdentity wi = WindowsIdentity.GetCurrent();
WindowsPrincipal wp = new WindowsPrincipal(wi);
if (wp.IsInRole(WindowsBuiltInRole.Administrator))
{
//Console.WriteLine("Admin");
Console.WriteLine(WindowsBuiltInRole.Administrator.ToString());
}

No comments: