Developing and Debugging Applications with Data Sources Across Domains

by Evan 22. March 2011 11:17

As a developer working mostly across multiple domains, I've found myself having to VPN in and out quite often in order to connect to different data sources. The first issue I dealt with was connecting to our TFS server while being VPN'd onto a domain. The work-around was simply right-clicking Visual Studio and selecting "Run As Administrator". This way I could connect to databases I have access to on a private domain along with our TFS server at the same time.

The next issue I had was debugging code that connected to data sources that needed Service Account credentials. Recently, I needed to create an SSIS package to connect to a data source that I did not have access to, however, I do have the service account credentials. One method of running the package was setting up a user/proxy in SSMS with the credentials and running the package as the proxy but this didn't allow me to debug locally.

The solution was using runas.exe to open Business Intelligence Dev Studio. This way I could run BIDS under the service account and access the data source locally! This helped dramtically in saving time debugging apps and allowed to run queries locally instead of RDP'ing onto other machines.

To run any app using the "runas" executable, first create a new shortcut and in the location box enter something similar to the following: 

C:\Windows\System32\runas.exe /netonly /user:SERVICE_ACCOUNT_USERNAME "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"

where we replace SERVICE_ACCOUNT_USERNAME with your service account name and "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" with the location\filename of the app you'd like to run.

When you open the shortcut you'll get a command prompt asking for the service account password (I've removed the account name).

After entering the password the app will allow you to access secure data sources on the domain successfully. So far I've used this method with Visual Studio, SSMS and BIDS. A great tip for any developer who needs to work locally.

Tag cloud