Archive for February, 2009

Login failed for user ‘NT AUTHORITY\ANONYMOUS LOGON’ error

February 26, 2009

I am working on my current FBA Management Suite implementation for a client, and everything worked perfectly on my local VM and on our Dev (Testing) environment.  But then after I deployed to Production I started getting these ‘Login failed for user ‘NTAUTHORITY\ANONYMOUS LOGON” errors that drove me nuts…After getting some help from our Senior Developer Josh Carlisle to track down the problem it turned out because on Dev and my local VM the Web Application and Database servers were on the same box, but production has them on different boxes so there was hopping involved.  When you login to the first box (Web App server) that is one hop, and then when you login to the second box (DB Server) thats another hop…and the problem was is that the identity is not kept and it will try to login as ‘NT AUTHORITY\ANONYMOUS’ and it doesnt have the permissions necessary to perform the required actions.  So as a work-around that worked for me, I wrapped my code that communicates with the DB server with the following:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    //Your code
});

And it worked just fine for me because when you do that then SharePoint will use the App Pool account which originally had permissions.