Thursday, December 24, 2020

Connect to MSSQL Server in another domain using Windows Authentication

cannot connect sql server windows authentication




When you need to connect to a Microsoft SQL Server in a different domain than the current domain you are in, you may face some problems. Because there can be a chance that the Server doesn’t allow connections from untrusted domains. This will be a huge problem if you only have windows authentication to that SQL Server and there will be no possibility to have SQL Authentication access created.

Most of the people having this problem found the easiest and quickest solution for this problem. The solution is to Remote to a computer in the same domain that the MS SQL Server in and then connect that server using Microsoft SQL Server Management Studio (SSMS). But again there will be limitations in this solution when you are working in a corporate environment because most of them have restricted to install the certain applications in their computers or if they might have limited the concurrent user access to those computers.

So if you are wondering is there any way we can remedy this problem without having SQL Authentication, or adding the particular computer to the required domain, Yes there is one way which we will discuss in this article. This solution will not only be limited to SQL Server, we can use this method for many applications that might use windows authentication run.

Connect using runas /netonly

In this method, we will use the windows built-in method run-as to run an application that needs windows authentication using Command Prompt.
runas /netonly /user:domain\username "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.exe"

 You can run the above command in the Command-line interface.

runas/netonly command

After running the command Command-line will prompt you to enter the password for the given user, then the provided application will attempt to run as the given user.

Then Microsoft SQL Server Management Studio (SSMS) will open and you can connect to the required Server and Database without any problem. If you got any authentication error, double-check the password you provided and try again.

Let’s say if you are connecting this Server and the Database frequently and then enter these details into the command prompt will be a little trouble for you. Don’t worry we have a solution for that problem as well. Then you can connect to the required MSSQL Server without any hassle.


The solution is to create a shortcut and then open it when required.


You can find the steps to create the shortcut below.


How to create a Shortcut to open the SSMS (With windows authentication)


Right-click on the desktop, Then Click on Shortcut


Enter the same command which we provided in the Command prompt earlier in the “Type the location of the item” box as below.

runas /netonly /user:domain\username "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.exe"


Then provide an easy name for your shortcut.
Your shortcut is ready now.

Just double click and open it, then provide your domain password and hit Enter.

Then Microsoft SQL Server Management Studio will open.



Provide your server name and select Authentication as Windows Authentication and press connect. Finally, you will have access to your Database

No comments:

Post a Comment