Authentication of a SQL connection using login information outside the domain

I am trying to connect to an SQL server from outside the domain.

I have the following connection string:

SqlConnection("SERVER=Server;DATABASE=Database;User ID=Domain\User;Password=password"); 

When I try to use this outside the domain, it will crash when I try to log in using SQL authentication.

Is there a way to pass a command to a string to use Active Directory authentication.

What other methods of connecting to the SQL server exist using active directory data outside the domain?

+7
source share
1 answer

You either need:

  • Use the built-in security in the connection string and create trust between the domain of your resource (where the SQL server is) and the domain of your account (where the account is located). Or...
  • Create an account on SQL Server and use it in your connection string as username and password.

You make an invalid mix by adding domain credentials to user / pass and there is not even a trust relationship.

EDIT:

The comments indicate the need to synchronize your SQL account with AD loans. It is not necessary. A sql account is simply a username and password for SQL that refers to the SQL server and has nothing to do with domain loans. If you use an SQL account, then they become the configuration settings of your application, which are used to build the correct connection and are sent via cable. The SQL server authenticates these creds locally without the involvement of AD.

It’s also interesting if you are creating a two-tier client (direct access to sql directly) or 3-tier (clients get access to a mid-level application server that accesses sql). If this is the last, your application authenticates and authorizes users, and after that it uses the configuration setting with the specific sql user / password in it to access sql. If this is the first one and you are using sql accounts, you need one client and that is the problem.

+3
source

All Articles