Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Trusted = yes/no mean in Sql connection string?

What does Trusted = yes/no mean in Sql connection string?

I am creating a connection string as below :

            string con= string.Format(
                "user id=admin;password=admin;server={0};Trusted_Connection=yes;database=dbtest;connection timeout=600",
                _sqlServer);

Please Help

like image 550
Ashish Ashu Avatar asked Aug 07 '09 05:08

Ashish Ashu


People also ask

What is SQL trusted connection?

A Trusted connection means Windows Authentication (i.e. a Windows login). SQL Server has two Authentication modes: Mixed and Windows Authentication Mode. Mixed has the option of SQL server logins (username and password) and Windows Authentication.

What is the use of trusted connection in connection string?

A trusted connection is used if you're connecting to the database without providing a user name and password. For example, if you are connecting via a Data Source Name, and the DSN contains the user ID you're using to connect, then your trusted connection is true.

How do I setup a trusted connection in SQL Server?

Configuring Microsoft SQL Server trusted connections on UNIX Provide the Windows service user name and password in the Microsoft SQL Server connection properties. Select the provider type as ODBC. Select the Use DSN check box. Click OK to create the connection.

How do I fix the SQL Server connection string?

Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.


3 Answers

Integrated Security or Trusted_Connection

When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication.

Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.

like image 101
Arsen Mkrtchyan Avatar answered Oct 25 '22 08:10

Arsen Mkrtchyan


Check out connectionstring,com for detailed description of all the various SQL Server connecion string properties. Specifically, this article:

like image 22
Jay Riggs Avatar answered Oct 25 '22 09:10

Jay Riggs


SSPI stands for Security Support Provider Interface.

The SSPI allows an application to use any of the available security packages on a system without changing the interface to use security services. The SSPI does not establish logon credentials because that is generally a privileged operation handled by the operating system.

Usually a .NETconnection string looks like this, of course you will have your own server, database names.

"Data Source=localhost\sql2012;Initial Catalog=AdventureWorks; Integrated Security=SSPI"

Other than SSPI you can also use "true".

Integrated Security actually ensures that you are connecting with SQL Server using Windows Authentication, not SQL Authentication; which requires username and password to be provided with the connecting string.

like image 20
sadiq Avatar answered Oct 25 '22 09:10

sadiq