Reputation: 1558
When I run my c# Windows Forms Application on Windows 7 with:
This code:
WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);
still returns false. Is this expected behaviour?
Upvotes: 1
Views: 1556
Reputation: 20157
I am pretty sure if the user is not an Administrator, Run As Administrator is not going to elevate that user's context for that application to that of Administrator. That would be a terrible security hole and end-run around enforced security of keeping users as normal users.
Upvotes: 2