Silverlight Student
Silverlight Student

Reputation: 4118

windows service running from Visual Studio 2010. Anyway to impersonate some user for LogOn

When a windows service is setup its run under a default network service logon. If I am debugging a windows service project from Visual Stduio, what logon credentials does it use? Also is there anyway to impersonate some other credentials when debugging this service from visual studio 2010?

Upvotes: 0

Views: 739

Answers (1)

DavidJBerman
DavidJBerman

Reputation: 955

Hi there Silverlight Student, You can easily debug a Windows service using Visual Studio and there are multiple ways to do it.

One way you can do it is start the windows service, and then go to the debug menu in visual studio, and then choose Attach To Process. You'll find your service in the list, and double click on that. Then you can trap break points, trace, and everything in the debugger. Depending on how you start the process, that will affect the user account it runs under.

A second way, is you can set your service so it can also be started by command line and even open up a console window. I explain how to do that, with sample code here: C# Windows Service: The service did not respond to the start

If you want to have the service run in a particular user context, you can go into the Windows Service Control Manager and configure what user your service runs as, then start it from there, and then use the attach to process approach to hook on using the debugger.

David

Upvotes: 2

Related Questions