.net - 使用 Windows 身份验证的连接字符串

标签 .net sql-server connection-string windows-authentication

我正在创建一个网站,但在数据库中我使用 Windows 身份验证。

我知道您使用它进行 SQL 身份验证

<connectionStrings> 
    <add name="NorthwindContex" 
       connectionString="data source=localhost;
       initial catalog=northwind;persist security info=True; 
       user id=sa;password=P@ssw0rd" 
       providerName="System.Data.SqlClient" /> 
</connectionStrings>

如何修改它以使用 Windows 身份验证?

最佳答案

将用户名和密码替换为 Integrated Security=SSPI;

所以连接字符串应该是

<connectionStrings> 
<add name="NorthwindContex" 
   connectionString="data source=localhost;
   initial catalog=northwind;persist security info=True; 
   Integrated Security=SSPI;" 
   providerName="System.Data.SqlClient" /> 
</connectionStrings> 

关于.net - 使用 Windows 身份验证的连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14270082/

相关文章:

c# - Mongo 更新数组元素(.NET 驱动程序 2.0)

c# - 实例化具有初始值的类型是否比两个单独的语句便宜?

asp.net - SQL 主键

sql-server - 在 RIGHT() 或 SUBSTRING() 中使用 CHARINDEX() 分割字符串返回不正确的结果

c# - |数据目录|的位置如何在连接字符串解决?

c# - 我将连接字符串与众多客户端放在哪里?

c# - Visual Studio 2013 远程调试、自动部署?

c++ - 将 SQLFetch() 与 SQL_C_FLOAT 一起使用时出现 "Numeric value out of range"错误

entity-framework - 使用单独的文件来维护 Entity Framework 的连接字符串

.net - 重载方法时返回不同类型是一种不好的做法吗?