Admin Prevlidges

  • Thread starter Thread starter Dennis C. Drumm
  • Start date Start date
D

Dennis C. Drumm

What is the best way to determine what access prevlidges the current user
has from within my running application? I need to insure the user has
administrator prevlidges for one particular function.

Thanks,

Dennis
 
Hi Dennis,

This best was is to create a WindowsPrincipal object out of the current
WindowsIdentity object [example below].

Cheers,
Steve Goodyear


using System.Security.Principal;
....
private void Form1_Load(object sender, System.EventArgs e)
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal user = new WindowsPrincipal(identity);
MessageBox.Show(
user.IsInRole(WindowsBuiltInRole.Administrator).ToString());
}
 
Steve,

Thanks a million! I thought it must be something fairly easy to do.

Dennis
 
Back
Top