[ACCEPTED]-Using advapi32.dll:LogonUserA() to impersonate a remote machine's local user-remote-access
Accepted answer
Here's what I have been using without having 3 to define a local user:
const int LOGON32_LOGON_NEW_CREDENTIALS = 9;
const int LOGON32_PROVIDER_DEFAULT = 0;
bool isSuccess = LogonUser(username, domain, password,
LOGON32_LOGON_NEW_CREDENTIALS,
LOGON32_PROVIDER_DEFAULT, ref token);
After that:
WindowsIdentity newIdentity = new WindowsIdentity(token);
WindowsImpersonationContext impersonatedUser = newIdentity.Impersonate();
I don't 2 duplicate the handle though.
Another observation 1 - I don't use LogonUserA, I simply use LogonUser.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.