Click here to Skip to main content
15,886,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

How it can be make sure that current user is administrator or having rights of administrator to run application. What are possibilities to testify that scenario.
Suggestions are required.
Thanks

Regards,
Itz.Irshad
Posted

1 solution

Something similar like this.

C#
method here
{ 
   WindowsIdentity identity = WindowsIdentity.GetCurrent();
     
   WindowsPrincipal user = new WindowsPrincipal(identity);

   string role = "BUILTIN\\Administrators";
   bool IsAdmin = user.IsInRole(role));
}
 
Share this answer
 
Comments
Mehdi Gholam 12-Apr-12 4:15am    
Nice, my 5!
Itz.Irshad 12-Apr-12 5:21am    
Dear AndreasJoh,
Will it cover those users who belongs to administrator group ?
Kindly update me.
Thanks

Regards,
Itz.Irshad

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900