bool returnValue = LogonUser("", "", "",
LOGON32_LOGON_BATCH, LOGON32_PROVIDER_DEFAULT,
out safeAccessTokenHandle);
WindowsIdentity.RunImpersonated(
safeAccessTokenHandle,
// User action
() => {
// Check the identity.
Console.WriteLine("During impersonation: " + WindowsIdentity.GetCurrent().Name);
}
);
bool returnValue = LogonUser("", "", "",
LOGON32_LOGON_BATCH, LOGON32_PROVIDER_DEFAULT,
out safeAccessTokenHandle);
WindowsIdentity.RunImpersonated(
safeAccessTokenHandle,
// User action
() => {
// Check the identity.
Console.WriteLine("During impersonation: " + WindowsIdentity.GetCurrent().Name);
}
);