What does Trusted = yes/no mean in Sql connection

2019-01-25 04:34发布

问题:

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

回答1:

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.



回答2:

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



回答3:

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.