Start a .Net Process as a Different User

Can you try something like this: Start a new Process as another user Code sample: System.Diagnostics.Process proc = new System.Diagnostics.Process(); System.Security.SecureString ssPwd = new System.Security.SecureString(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = “filename”; proc.StartInfo.Arguments = “args…”; proc.StartInfo.Domain = “domainname”; proc.StartInfo.UserName = “username”; string password = “user entered password”; for (int x = 0; x < password.Length; x++) … Read more

Windows Impersonation from C#

It’s possible, although it requires you to do a lot of code. See NtCreateToken and CreateToken. You need SeCreateTokenPrivilege, although that won’t be a problem since you’re running under NT AUTHORITY\SYSTEM. You can then use the created token to impersonate inside a thread.

How to get Windows user name when identity impersonate=”true” in asp.net?

With <authentication mode=”Windows”/> in your application and Anonymous access enabled in IIS, you will see the following results: System.Environment.UserName: Computer Name Page.User.Identity.Name: Blank System.Security.Principal.WindowsIdentity.GetCurrent().Name: Computer Name With <authentication mode=”Windows”/> in your application, and ‘Anonymous access’ disabled and only ‘Integrated Windows Authentication’ in IIS, you will see the following results: System.Environment.UserName: ASPNET (user account used to … Read more

How to use LogonUser properly to impersonate domain user from workgroup client

Very few posts suggest using LOGON_TYPE_NEW_CREDENTIALS instead of LOGON_TYPE_NETWORK or LOGON_TYPE_INTERACTIVE. I had an impersonation issue with one machine connected to a domain and one not, and this fixed it. The last code snippet in this post suggests that impersonating across a forest does work, but it doesn’t specifically say anything about trust being set … Read more

How do you do Impersonation in .NET?

“Impersonation” in the .NET space generally means running code under a specific user account. It is a somewhat separate concept than getting access to that user account via a username and password, although these two ideas pair together frequently. Impersonation The APIs for impersonation are provided in .NET via the System.Security.Principal namespace: Newer code should … Read more