Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to impersonate another user?

I'm working on an ASP.net app and i'm trying to impersonate a user

I'm creating a windowsIdentity with a token

WindowsIdentity winId = new WindowsIdenty( token );

this token was got by calling the un managed code

[DllImport("advapi32.dll")]
public static extern int LogonUserA(String lpszUserName, 
    String lpszDomain,
    String lpszPassword,
    int dwLogonType, 
    int dwLogonProvider,
    ref IntPtr phToken);

is there any other way to get a token without using this advapi32.dll unmanaged code?

tks

like image 876
DJPB Avatar asked Feb 17 '10 17:02

DJPB


People also ask

How do you impersonate a user?

Impersonate a user Click the name of an individual user to view the detail page. Click the Impersonate link next to the user's name.

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.

Where is the impersonate user feature located?

In the User's details page, click the Actions button in the top right corner and select Impersonate to assume the User's identity. You will be taken to the User's homepage, and in the top right corner, you will see the User's name with [Impersonating] showing beside it.


1 Answers

Personally, I prefer a wrapper class to handle this Impersonation.

So, you will be working with unmanaged code, but AFAIK there is no way to do this with managed code directly.

like image 98
jpabluz Avatar answered Sep 22 '22 20:09

jpabluz