集成安全 = True 和集成安全 = SSPI 之间有什么区别?
-
22-07-2019 - |
题
我有两个使用集成安全性的应用程序。一项分配 Integrated Security = true
在连接字符串中,以及其他集合 Integrated Security = SSPI
.
有什么区别 SSPI
和 true
在集成安全的背景下?
解决方案
根据微软的它们是相同的东西。
当在连接中指定
false
,用户ID和密码。如果为true,当前的Windows帐户凭据用于验证。点击 识别的值为true
,false
,yes
,no
,和sspi
(强烈推荐),其等同于true
。
其他提示
与Integrated Security=true;
提供商使用时OleDb
并不适用于所有SQL提供商合作,它抛出异常。
因此,基本上Integrated Security=SSPI;
是因为与两个SQLClient
&OleDB
提供商作品优选的。
是Windows认证强> 的
要连接到数据库服务器,建议使用Windows身份验证,俗称集成安全。要指定Windows身份验证,您可以使用任何以下两个键 - 值对与数据提供者。对于SQL Server .NET Framework的:
Integrated Security = true;
Integrated Security = SSPI;
然而,只有第二作品与所述数据提供者的 .NET框架的OleDb 。如果您的ConnectionString例外设置Integrated Security = true
被抛出。
要指定数据提供者的Windows身份验证。用于ODBC .NET框架,应该使用以下键值对。
Trusted_Connection = yes;
来源: MSDN:使用连接字符串 <工作/ p>
许多问题得到解答,如果我们使用.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;
}
}
...
修改2018年2月20日强> 现在,在对.NET核心,我们可以看到在github其开源! 搜索ConvertValueToIntegratedSecurityInternal方法:
集成安全=假:用户ID和密码被在连接中指定。 集成安全性=真:当前的Windows帐户凭据用于身份验证
集成安全性= SSPI:这是equivalant为true。
我们可以避免用户名和密码的连接字符串属性和使用集成安全性
让我开始Integrated Security = false
<强> false
用户ID和密码被连接字符串中指定。结果
的 true
强> Windows帐户凭据用于身份验证。
识别的值为true
,false
,yes
,no
,和SSPI
。
如果User ID
和Password
指定和集成安全性设置为true
,然后User ID
和Password
将被忽略和集成安全将用于
真才有效,如果你使用.NET的SqlClient库。它使用OLEDB时无效。 其中SSPI被bvaid在两者或者您使用.NET的SqlClient库或OLEDB。
在我的观点来看,
如果你不使用集成的安全性= SSPI,那么你需要硬编码的连接字符串中的用户名和密码,这意味着“相对不安全”为什么,因为,所有的员工都访问甚至前雇员可能会恶意使用这些信息。