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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With