在.NET 4中保留安全信息

6
你使用Microsoft Visual Studio 2010和Microsoft .NET Framework 4创建应用程序。该应用程序连接到Microsoft SQL Server 2008数据库。 应用程序使用Microsoft ADO.NET SQL Server托管提供程序。当连接失败时,应用程序记录连接信息,包括完整的连接字符串。该信息以纯文本形式存储在.config文件中。
你需要确保数据库凭据是安全的。
你应该将哪个连接字符串添加到.config文件中?
A. Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=false;
B. Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=true;
C. Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=false;
D. Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=true;
根据指南,答案是“A”。但我认为答案是“C”。如果我们使用Integrated Security = SSPI,则不需要提供UserID和Password。因此,Persist Security Info=false没有任何效果。
据我所知,只有当连接字符串具有用户凭据时,Persist Security Info才会生效。
请问您认为哪个答案是正确的?谢谢。
1个回答

5
您说得对。Persist Security Info=false 仅在连接字符串中提供用户名和密码时才有效。但问题是“应该在 .config 文件中存储什么信息”,考虑到“信息以纯文本形式存储”,您不应该在 config 文件中存储 UID 和 PWD。
如果您存储 C,则可以从 .config 文件中提取 PWD 和 UID。但如果您存储 A,则无法提取凭据。
我不确定为什么 A 具有“Persist Security Info=false”,但看起来这是一个好的实践。请参阅 MSDN 示例:

但看起来这是一个好的实践,但它看起来非常冗余,因为默认值是“false”。 - ta.speot.is

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接