How to debug multiple services in same solution as different users per service?

1.2k views Asked by At

Core Question

Given a solution that has multiple projects (A console app and two services, along with some shared libraries), how can I debug the solution (w/breakpoints in both web services + console) if each service needs to run under it's own service account?

Ideal

Set up the project to allow the F5 debugger to immediately attach to both services and the console, while running each service under its own account.

Project Set up

I have a single solution with multiple start entries. I already have it set up to launch each entry point when I click debug, but run into issues actually testing as the database requires the use of windows auth for each service account to connect, but the two services require different service accounts.

Solution:

  • Common Library (shared by all 3 projects)

  • Service 1 (WCF, needs to run as EXAMPLEDOMAIN/ServiceAccount1_DEV)

  • Service 2 (WebAPI, needs to run as EXAMPLEDOMAIN/ServiceAccount2_DEV)

  • Console application (needs both services, don't care what account this runs under)

  • Each service is talking to different physical databases, it is not possible to

Tried so far/things I cannot try

In previous versions of VS, I used VSCommands's DEBUG AS to solve this issue, but that project appears to be dead for VS 2015.

Tried to run visual studio itself as the various service accounts, but run into a "Trial period expired" message if not running it as myself.

Tried to use "C:\Windows\System32\cmd.exe /C runas /savecred /user:ServiceAccount#_DEV DebugTarget.Exe", which works for the console but I haven't figured out how to launch a service with this.

I cannot use a different version of VS, as I am in a locked down corporate environment and only have VS 2015 installed.

I can use plugins on manager approval but have no budget for them, so a plugin like VSCommands is an acceptable answer for my case, but only if it is free.

I cannot change the SQL permissions, as each service is talking to separate physical databases which do not share permissioning.

Edit: Missing ideal outcome block.

1

There are 1 answers

1
Jack Zhai On BEST ANSWER

Solution:

One idea is that just turn to the project property to change the IIS Express to local IIS, and then run two projects with two account in IIS.

Another thread also discussed the same issue here:

how to run iisexpress app pool under a different identity