2013-01-11 45 views
81

我正在創建一個網站,但在數據庫中我使用Windows身份驗證。使用Windows身份驗證的連接字符串

我知道,你用這個SQL認證

<connectionStrings> 
    <add name="NorthwindContex" 
     connectionString="data source=localhost; 
     initial catalog=northwind;persist security info=True; 
     user id=sa;[email protected]" 
     providerName="System.Data.SqlClient" /> 
</connectionStrings> 

如何修改這個Windows身份認證的工作?

回答

132

替換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> 
+1

我知道你可以將特定的AD用戶設置爲應用程序池(web應用程序)。你可以做同樣的Windows應用程序? – user384080

+4

'Persist Security Info'可能不需要:http://stackoverflow.com/a/2010059/1869660 – Sphinxxx

+0

@ heads5150:有沒有可能我的項目中沒有連接字符串?我錯過了什麼。我已經搜遍了我的整個解決方案,找到上面的連接字符串。我找不到任何。我創建的那個在網絡發佈和網絡配置中被評論了..我使用vs express 2013與本地數據庫。 – Vini

0

這是更短,工作

<connectionStrings>  
<add name="DBConnection" 
      connectionString="data source=SERVER\INSTANCE; 
     Initial Catalog=MyDB;Integrated Security=SSPI;" 
      providerName="System.Data.SqlClient" /> 
</connectionStrings> 

堅持安全信息不需要

0

對於多小時後正確的解決方案:

  1. 打開配置文件
  2. 更改連接字符串與下列

<add name="umbracoDbDSN" connectionString="data source=YOUR_SERVER_NAME;database=nrc;Integrated Security=SSPI;persist security info=True;" providerName="System.Data.SqlClient" />

  • 更改您的服務器名與當前服務器名並保存
  • 打開IIS管理器
  • 查找網站或Web應用程序使用
  • 右鍵單擊並選擇高級設置
  • 從高級設置下過程模型改變身份到自定義賬號,並添加應用程序池的名字你服務器管理的詳細信息,請參閱附件圖片:
  • enter image description here

    希望這會有所幫助。

    相關問題