• Home /
  • Blog /
  • How to run programs as a domain user from a non domain computer
sql-server-tutorials.png

How to run programs as a domain user from a non domain computer

On my current contract I have to develop and support SSIS packages for multiple versions of SQL server and in order to work with multiple versions, I am running a virtual machine.

The problem with virtual machines they are not connected to active directory, and in most cases, I need to connect to SQL Server using Management Studio using Windows Authentication.

Usually in the past, when I need to run the application under a different account, I used ShellRunAs application from Sysinternals, it creates a nice context menu which allows to type credentials for the different user, but in this case, it did not work, because I was running it from the virtual machine. It complained that "The username or password is incorrect".

The solution for this issue is to provide an additional parameter to ShellRunAs application

/netonly - Use if specified credentials are for remote access only

The problem ShellRunAs accept this parameter when it runs from command line and there is no UI to run the application with that command. But this can be fixed by creating another context menu item which will have such a parameter.

ShellRunAs registered for multiple file formats under Shell key in Windows registry. For example, for *.exe files, it registered at HKEY_CLASSES_ROOT\SystemFileAssociations\.exe\Shell\

it also registers for link files and msc files (Microsoft management console)

The registry files need to be modified for your system to use the correct location where ShellRunAs.exe file is located, in my case it's c:\Sysinternals\ShellRunas.exe

Now, after I have executed registry files, I can see another context menu

Executing Microsoft SQL Management studio under domain account from non-domain computer

If you like command prompt, the same can be achieved using RunAs command, it does not have GUI but works absolutely the same (you can use both Powershell and Cmd). On the sample below I am running Microsoft Management Studio from a machine not connected to the domain


PS C:\> runas /netonly /user:alex.shapovalov@domain.com "C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"
Enter the password for alex.shapovalov@domain.com:
Attempting to start C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe as user "alex.shapovalov@domain.com" ...
PS C:\>
		

As a result after my SQL Management studio starts I am able to access all database under my domain account and SQL Management studio is actually running under my domain account

Get latest updates directly into your inbox


Comments

Yaplex logo white text

Yaplex is an IT Consulting and .NET development company co-founded by .NET Developer Alex Shapovalov who lives in Mississauga and provides software development services in Toronto, Mississauga, and GTA.

Contact Information

Toronto, Canada
Phone: +1 647 328 3809