WindowsIdentity identity = new WindowsIdentity(accessToken);
WindowsImpersonationContext context = identity.Impersonate();
...
context.Undo();
Where do i declare a administraotr UserName and Passowrd ?
the accessToken param doesn't help me too much...
Do I have to import DLL'S for it ?
its exactly the accesstoken you have to use. to get it you need to call the LogonUser method:
oops didnt realise that i just have the VB.net code just here. imagine it in C# ;) here in c#
external method declaration:
and the execution:
You need to get the user's token. Use the p/invoke
LogonUser
from the advapi32.dll:Example:
You need to P/invoke the
LogonUser()
API. That accepts username, domain and password and returns a token.