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
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.
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.
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.
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.
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.
Check out connectionstring,com for detailed description of all the various SQL Server connecion string properties. Specifically, this article:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With