• Home /
  • Blog /
  • How to run programs as a domain user from a non domain computer

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 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 application under different account, I used ShellRunAs application from Sysinternals, it creates a nice context menu which allows to type credentials for different user, but in this case it did not work, because I was running it from virtual machine. It complained than "The username or password is incorrect".

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

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

The problem ShellRunAs accept this parameter when it run from command line and there is no UI to run application with that command. But this can be fixed by creating another context menu item which will have such 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 correct location where ShellRunAs.exe file is location, 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 machine not connected to 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



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