In my website I am accessing my sqlserver database using "windows authencation mode". Everything works fine when I run my website using visual studio. but when I hosted my website on IIS, everytime an error message comes that "database login failed".
Login failed for user 'HAL\IUSR_HAL'.(HAL is the name of my webserver)
Should I do some modifications in database properties so that I can login to database through IIS?
After some research i got the answer of this question.
To access the database through a website running on IIS , IIS's IUSR account and ASPNET account should be authenticated and authorized to sqlserver.
(ASPNET account is the account of dotnet framework associated with IIS to process asp.net pages.)
to do this:
open Sqlserver management studio. go to SECURITY. then right click on LOGIN and select "new login". press "search" on login name. then click "advanced" button. Then press "find now" button. then from list appeared select both of the accounts mentioned above.(one at a time) then press ok. after selecting the login name go to it's "user mappings" options. then select the database from there and check the desired permissions.
now you are done with everything. press ok.
you can access database from ur website.