Getting a list of Roles a user belongs to using Windows Security Principal

  • Thread starter Thread starter vivek
  • Start date Start date
V

vivek

Hi

I have created a windows application in .NET using C# here is the Code
Snipp

public static void Main() {
...
// Tell the CLR to use Windows security
AppDomain.CurrentDomain.SetPrincipalPolicy(
PrincipalPolicy.WindowsPrincipal);
// Get the current principal object
WindowsPrincipal prin =
(WindowsPrincipal) Thread.CurrentPrincipal;
// Determine whether the user is an admin
Boolean fAdmin = prin.IsInRole(WindowsBuiltInRole.Administrator);
Console.WriteLine("Administrator:" + fAdmin);
}

As you can see I can determine if the current user belongs to Adminstartor,
but is there a method
where I can get the list of Roles that a particualr use belongs to.

Moreover what is the String equivalent of WindowsBuiltInRole.Administrator
so that I can use that
string in the method

WindowsPrincipal.IsInRole(String);


voeivk
 
Back
Top