Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given a username and password, how do you impersonate that user elevated?

In Windows Vista and later, LogonUser returns a non-privileged token, even if the user provided is an administrator. Thus, when you impersonate using that token, you are non-elevated. Given a correct username and password for an administrator user, how do you run code that has elevated privileges for that administrator?

like image 264
Mark Raymond Avatar asked Sep 27 '13 12:09

Mark Raymond


People also ask

How do you impersonate a user?

Activate user impersonationSign in to Google Ad Manager. Roles. Select the role you want to edit. Check the Impersonate users (read-only) checkbox if you only want to permit users in this role to view the UI as another user, or check Impersonate users (read/write) to permit these users to make changes.

How do I impersonate a user in ServiceNow?

Impersonate a user from the main ServiceNow browser window (not App Engine Studio). Open the User menu by clicking your user name in the ServiceNow banner. Select the Impersonate User menu item. In the Impersonate User dialog, enter the name of the user to impersonate in the Search for user field.

What is the Selected to impersonate another user?

To impersonate another user, the impersonator selects the Impersonate icon on the far right of the Tab Bar and selects the user from the Impersonate drop-down list. To stop impersonating a user, the impersonator clicks the Impersonate icon and selects Stop Impersonate from the Impersonate drop-down list.


1 Answers

I just worked with this example, It actually works fine. I guess if you want to run code in this context you'll have to set the current thread principal by:

Thread.CurrentPrincipal = new System.Security.Principal.WindowsPrincipal(WindowsIdentity.GetCurrent());
like image 159
MichaC Avatar answered Oct 31 '22 19:10

MichaC