change web application authentication to use Windo

2019-09-19 06:11发布

问题:

I'm trying to publish my web application on IIS 8.5, but I'm getting this error when the application tries to retrieve data from the SQL Server 2008.

InnerException: {Message:An error has occurred., ExceptionMessage:Login failed for user 'domainname\WES-JXC2J02$'.,…} ExceptionMessage: "Login failed for user 'domainname\WES-JXC2J02$'."

The SQL Server doesn't have WES-JXC2J02$ listed as the authorized user because it's my dev machine name. If I try to add the machine name as user in SQL Server it gives me an error because there's no such user in the domain. I want to use Windows Authentication which is set to enable in IIS. What can I do to fix it?

回答1:

So, apparently, as @MikeCheel said, it was forwarding my machine credentials to the SQL Server to retrieve the data from the database. Turned out, I needed to create a new login in SQL Server with limited access, then add the user id and password in the connectionString. I learnt it the hard way that SQL Server must have SQL and Windows Authentication enabled. Once that was configured, connection was setup and the data displayed properly.