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

Posted on 2014-08-26
Last Modified: 2014-09-04
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.
Question by:dodgerfan
    LVL 29

    Assisted Solution

    Was the 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.
    LVL 29

    Expert Comment


    A possible solutionthat I should have included in my comment above
    LVL 12

    Accepted Solution

    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

    Author Closing Comment

    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now