Mike Christian
Mike Christian

Reputation: 1536

Debug while Impersonating Another Domain Account

Is it possible to debug a C# .NET 4 application, run unit tests, etc., using domain user credentials other than my own? I have several elevated permissions that the users and/or service accounts will not posses, and want to avoid skewing my tests and ultimately suffering from "it works on my machine" syndrome.

I specifically want to create a SqlConnection object that uses a domain service account, rather than my own. I must use a domain account, and not SQL Server account, to allow SQL Server to emit PEXEC calls to other hardware. (Sounds fun, eh?)

I am surprised the option to run debug/release as a different domain user is not already setting in the solution/project Debug properties panel. It seems like something that would be useful. Sure, I understand the security risks, but you have to admit that would be very useful in many cases.

Thanks in advance!

Upvotes: 4

Views: 2225

Answers (1)

dizzwave
dizzwave

Reputation: 4479

Possible duplicate of this question? (Using VSCommands addon)

Or this cheap way, from VBForums:

Create your executable, then using "Run As" execute it under the normal user's credentials. Once it starts, open an instance of VS and attach the debugger to it.

Upvotes: 6

Related Questions