“Login failed for user ''” when trying to use Windows Authentication

拜拜、爱过 提交于 2019-12-13 15:22:06

问题


On my ASP.NET web.config I have the connection string:

initial catalog=DatabaseName; data source=(local); Integrated Security=SSPI;MultipleActiveResultSets=True; Connect Timeout=200;

I've used this connection string for Windows Authentication before, but now I'm getting the error:

Login failed for user ''.

This seems like its a SQL Authentication error, and that the username is blank as I have not supplied either a username or password.

Why is the application attempting SQL Authentication and not Windows?

How can I resolve this issue?


回答1:


For your connection string to work from ASP.NET application, your request must be running under user identity that can access SQL Server. By default, it will use identity of app pool worker process and generally, this identity is a local user (on the server) that does not have access to SQL Server. So you may try changing this identity to see if that help.

If you want to use identity of the windows user that is accessing your ASP.NET site then you have turn integrated authentication on in both IIS and ASP.NET. You also need to turn on the ASP.NET impersonation so that ASP.NET request will execute on the user's identity.

If you are still facing the issue then you might be facing double hop issue related to windows authentication (see two links sighted in the article for more info and trouble shooting).



来源:https://stackoverflow.com/questions/7659569/login-failed-for-user-when-trying-to-use-windows-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!