JD.*_*JD. 502 sql-server security connection-string database-security
我有两个使用集成安全性的应用程序.一个分配Integrated Security = true连接字符串,另一个分配Integrated Security = SSPI.
是什么区别SSPI,并true在集成安全性的情况下?
小智 410
据微软称,他们是一回事.
何时
false,在连接中指定了用户ID和密码.如果为true,则使用当前Windows帐户凭据进行身份验证.
识别的值为true,false,yes,no,和sspi(强烈推荐),这相当于true.
Pra*_*ngh 152
Integrated Security=true;在所有SQL提供程序中都不起作用,它在与OleDb提供程序一起使用时会引发异常.
所以基本上Integrated Security=SSPI;是首选,因为SQLClient与OleDB提供者兼容.
这是根据MSDN的完整语法集- 连接字符串语法(ADO.NET)
Ase*_*are 65
使用Windows身份验证
建议使用Windows身份验证(通常称为集成安全性)连接到数据库服务器.要指定Windows身份验证,可以将以下两个键值对中的任何一个与数据提供程序一起使用.用于SQL Server的.NET Framework:
 Integrated Security = true;
 Integrated Security = SSPI;
但是,只有第二个适用于数据提供程序.NET Framework OleDb.如果Integrated Security = true为ConnectionString 设置,则抛出异常.
在数据提供程序中指定Windows身份验证.在.NET Framework for ODBC中,您应该使用以下键值对.
Trusted_Connection = yes;
来源:MSDN:使用连接字符串
Pav*_*kov 30
如果我们.Net Reflector用来查看SqlConnection:)
 的实际代码true并且sspi是相同的,那么很多问题都会得到答案:
internal class DbConnectionOptions
...
internal bool ConvertValueToIntegratedSecurityInternal(string stringValue)
{
    if ((CompareInsensitiveInvariant(stringValue, "sspi") || CompareInsensitiveInvariant(stringValue, "true")) || CompareInsensitiveInvariant(stringValue, "yes"))
    {
        return true;
    }
}
...
编辑20.02.2018 现在在.Net Core我们可以在github上看到它的开源!搜索ConvertValueToIntegratedSecurityInternal方法:
小智 21
Integrated Security = False:在连接中指定用户ID和密码.Integrated Security = true:当前Windows帐户凭据用于身份验证.
集成安全性= SSPI:这与真实相当.
我们可以避免连接字符串中的用户名和密码属性,并使用集成安全性
kud*_*ger 13
让我先谈谈 Integrated Security = false
false  用户ID和密码在连接字符串中指定.
true  Windows帐户凭据用于身份验证.   
可识别的值为true,false,yes,no,和SSPI.
如果User ID和Password指定,并集成安全性设置为true,那么User ID与Password将被忽略,集成的安全性将使用
小智 7
需要注意的是连接字符串特定于什么和如何您要连接到的数据.它们连接到同一个数据库,但第一个是使用.NET Framework Data Provider for SQL Server.Integrated Security = True对OleDb不起作用.
如有疑问,请使用Visual Studio Server Explorer数据连接.