2014-04-22 135 views
0

我不得不從SQL Server身份驗證更改爲Windows身份驗證:從SQL Server更改連接字符串的Windows身份驗證

我的SQL Server身份驗證字符串是:

<add name="GCDataContext" 
     connectionString="Data Source=111.78.152.64;Initial Catalog=GC;User Id=sa;Password=xxxx;Trusted_Connection=False;Persist Security Info=True;MultipleActiveResultSets=True" 
     providerName="System.Data.SqlClient" /> 

改爲(非工作)

<add name="GCDataContext" 
     connectionString="Data Source=111.78.152.64;Initial Catalog=GC;Persist Security Info=True;Integrated Security=True;" 
     providerName="System.Data.SqlClient" /> 

任何人都可以幫助我嗎?

Integrated Security=True用於Windows身份驗證,但連接未建立。

+0

做一個測試UDL文件,以獲得參考windows身份驗證連接字符串。 – Hassan

+1

SQL服務器是否啓用了Windows驗證?應用程序運行在哪個帳戶? (提示:對於asp.net,它可能不是一個有用的) - 該帳戶是否有權訪問服務器?和數據庫?最重要的是:究竟是什麼**是錯誤信息? –

+0

一方與sa連接,另一方與當前連接的windows用戶連接。該用戶是否具有訪問數據庫的適當權限? –

回答

1

ASP.NET應用程序默認情況下不冒充。因此,當他們使用Windows身份驗證連接到SQL Server時,他們使用Web應用程序的進程標識。通過這種方法,您的前端Web應用程序會對其用戶進行身份驗證和授權,然後使用可信身份來訪問數據庫。數據庫信任應用程序的身份並信任應用程序以正確認證和授權呼叫者。

步驟1.配置一個連接字符串:

要使用Windows身份驗證,請執行以下步驟連接到SQL Server。 使用Windows驗證的連接字符串必須包含在Trusted_Connection =是屬性,或等效的屬性集成安全性= SSPI,

步驟2.配置SQL Server安全性: 您需要爲應用程序創建的SQL Server登錄服務帳戶,並授予訪問數據庫的受限權限。 您應用程序的服務帳戶通常是網絡服務帳戶,該帳戶是用於在Windows Server 2003和IIS 6.0上運行ASP.NET應用程序池的默認帳戶或自定義服務帳戶。

對於此作出以下

    a).Create a SQL Server login for your application's account. 
       b).Map the login to a database user in the required database. 
       c). Provide appropriate permissions 
0

< add name =「GCDataContext」connectionString =「Data Source = 111.78.152.64; Initial Catalog = GC; Integrated Security = True;」 providerName =「System.Data.SqlClient」/ >

Remove:Persist Security Info = True; 如果無法連接驗證DB權限和特權。

+0

@ sachin-crac:我試過了。沒用。 – user1282609

1
<add name="GCDataContext" 
     connectionString="Data Source=111.78.152.64;Initial Catalog=GC;Integrated Security=True" 
     providerName="System.Data.SqlClient" /> 

這應該有效。

你只需要刪除Persist Security Info=True
你也可以複製我上面的代碼

相關問題