9

I have an (.Net Console App) EXE which connects to various SQL databases using SQL server Authentication with appropriate credentials. Now there is change required in the EXE to use windows authentication and use the Network Credentials to log in SQL server. (All SQL servers are on diffrent locations) I have the network credentials with me, but am confused how to connect to remote SQL server using these and retrive data from that. Please help.

1
  • Which way are you using to connect to sql server? Entity Framework? Linq to Sql? Ado.NET?
    – Vinicius Ottoni
    Feb 8, 2012 at 13:41

4 Answers 4

11

The only change required is in the connection string: remove the User ID=...; and Password=...;, and add Integrated Security=SSPI; instead.

More information can be found here.

6

You need to modify your connection strings to follow the below format for a Trusted Connection:

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

And then run your application in the security context of the domain user.

1

Your app.config file should use Integrated Security in your connections strings.

0
string connectionString = "Server=.\\SQLEXPRESS01;Database=db_name;Trusted_Connection=Yes"

using (SqlConnection connection = new SqlConnection(connectionString))

Where Trusted_Connection=Yes attribute is equivalent to Integrated Security=SSPI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.