Have debugger run application as different user?
-
Wednesday, November 25, 2009 3:13 PM
I find myself having issues when I push my applications out to testing because I'm not catching a lot of database permissioning issues in debug. The problem is that I write my SQL in Visual Studio and work on my application. I'm running VS as a user who has full access to the database because I need it to run queries. When I debug my application, I'd like to run it under a different user so that I can catch permissioning issues.
How do other people deal with this issue?
All Replies
-
Thursday, November 26, 2009 2:09 AMYou can set infinite loop in your app and run it under aonther user, then attach debugger to the process
also you can start visual studio with another user, and start debugging. -
Thursday, November 26, 2009 3:40 AMModerator
Hi,
Thanks for your post.
I found a similar issue at: http://stackoverflow.com/questions/1287099/runas-a-different-user-when-debugging-in-visual-studio
If you set the command line in debug external program, Vsual Studio will always attach to the cmd.exe process. It doesn't support attach to a spawned process.
In order to debug that process, I summarize a workaround which is similar with Lei's solution:
1. Writing the following code at the beginning of your application
System.Diagnostics.Debugger.Launch();
2. Run the following command in cmd console
runas /savecred /user:OtherUser DebugTarget.Exe
When the application starts, it will first ask for the user's password. After it runs to the debugger.launch code, windows will pop up a window to let you choose to use a new VS or existing on to debug the application.
Hope it helps.
Hongye Sun [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer by Hongye Sun - MSFTModerator Thursday, December 10, 2009 1:58 AM
-
Thursday, December 10, 2009 1:58 AMModerator
Please let me know if this issue is still not resolved. Thanks.
Hongye Sun [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Monday, September 13, 2010 10:41 PM
If you're on VS2010 you can then use VSCommands Pro to start debugging as a different user directly from IDE.- Proposed As Answer by João Paulo Menezes Friday, March 25, 2011 3:23 PM

