• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1859
  • Last Modified:

SharePoint application page giving error 'Login Failed for user NT Authority\Anonymous Login'

I have a web page in SharePoint 2013 that is trying to call an external SQL Server database. Whenever you click a button to open the connection I get the error mentioned, 'Login Failed for user NT Authority\Anonymous Login'. The code and connection itself work in a regular .net web application. But it does not in SharePoint. I have added the user NTAUTHORITY\IUSR and given it the permissions. I have tried putting into the connection code a domain user name and password. I believe it must be something with SharePoint (which have a weeks worth of experience with), but that's because it all works correctly in a ASP.Net web application. What do I need to do to get it working within SharePoint? Thanks.
  • 2
2 Solutions
Was the asp.net application on the same server as sql server and/or using kerberos
You may be running into the double hop issue.
Client talks to sharepoint server who in turn talks to sql server (double hop).
Sharepoint server has not been given delegation rights and therefore is unable to provide SQL with the credentials of the calling client.


A possible solutionthat I should have included in my comment above
Ammar GaffarSoftware EngineerCommented:
If you are using windows authentication to access SQL Server in your web part, then the token which will be used is SharePoint token (NT Authority\Anonymous) for anonymous or logged in user to the SharePoint site.

You may try two solutions:
1- Run your SQL server call code with Elevated permission, and add permission to your SQL Server to the application pool user (you can find this user in IIS application pools).

2- Try to use SQL Authentication, create SQL standard user account in your SQL Server database and use it in your web part connection string.

Good Luck
dodgerfanAuthor Commented:
Sorry for the delay and thanks for the input. We ended up going back to mixed mode authentication on our SQL Server. It was at Windows only for reasons I am not clear on. But once it was switched to mixed, everything worked fine. I'm not sure if this is the complete answer, as windows only may be a requirement down the road, but for now problem solved.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now