2016-10-26 2 views
0

다른 서버에서 2 개의 다른 DB를 사용하는 MVC 응용 프로그램이 있습니다. 하나의 DB는 서비스 계정을 사용하고 다른 하나는 Windows 인증을 사용합니다. Windows 사용자 이름은 다른 도메인의 사용자 이름입니다. 그래서 나는 Windows 사용자로 가장하고 ADO.Net을 사용하여 DB를 질의했습니다.IIS에서 호스팅 한 후 SQL을 연결할 수 없습니다.

using (new Impersonation(domain, username, password)) 
{ 
    //code to fetch the data using ADO.Net 
} 

이 코드는 아래 링크에서 가져 왔습니다.

How do you do Impersonation in .NET?

그것은 내 로컬 컴퓨터에서 잘 작동한다. 그러나 IIS에 게시 할 때 아래 오류가 발생합니다. (서비스 계정을 사용하여 DB가 잘 작동)

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

내가 IIS에 어떤 권한이나 설정을 추가해야합니까. IIS는 호스팅 된 서버에 SQL Server Management Studio가 없으며 로그인 및 확인합니다.

답변

0

에 한번 당신의 선 위에 Web.config 파일, "foo는"과 "바"

<system.web> 
    <identity impersonate="true" userName="foo" password="bar"/> 
</system.web> 

을 추가 도와주세요하면 IIS 서버가 호스팅되는 컴퓨터의 사용자 이름과 암호입니다.