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.
dodgerfanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
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.

http://blogs.msdn.com/b/besidethepoint/archive/2010/05/09/double-hop-authentication-why-ntlm-fails-and-kerberos-works.aspx
0
QPRCommented:
http://technet.microsoft.com/en-us/library/cc739764(v=ws.10).aspx

A possible solutionthat I should have included in my comment above
0
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.