I have a webpage that uses SQL Server ID to connect to the database. I want this webpage to use the Domain User ID of current user to connect to the SQL Server database. For example, if user ABC accesses the page, the website will use credentials of Domain\ABC to connect to the database. But If user XYZ opens the page, the website will connect to SQL server using credentials of Domain\XYZ.
To do that, I performed following changes:
Code change:
'(Old Code) MyConnection = New SqlConnection("server=SeRVeRNaMe;database=DBname; User ID=SQL_UserID1; password= SQL_Password1")
MyConnection = New SqlConnection("server= SeRVeRNaMe;database=DBname; Integrated Security=SSPI ")
Web Config. Change: Added Following:
< authentication mode="Windows"/>
< identity impersonate="false" />
IIS Change: IIS 6.0 -> Properties of Virtual Directory -> Directory Security tab -> Edit -> Unchecked All, only checked ‘Integrated Windows Authentication’.
I also made sure that my Domain User ID has access to the database.
After all these changes, when I open the webpage, It gives error as it picks the Domain\WebServerName$ as ID instead of my Domain User ID. Could you please suggest me what I need to modify to make it work.?
Following is the error: [SqlException (0x80131904): Login failed for user 'Domain\WebServerName$'.]
Note: I have changed my actual Domain and Web Server name with Domain and WebServerName.