I have an ASP.NET web form application that on the server side I need to know the user’s identity. I do not need to impersonate the user. I just need their username so I can update some records in a database correctly.
When the request is processed I have the following line of code:
string userName = Request.LogonUserIdentity.Name;
if(true == string.IsNullOrEmpty(userName))
{
logger.logwarning("missing username");
}
else
{
logger.loginfo("update by {0}", userName);
}
In my development & QA environment this works perfectly – I see the userName in the log file and all of the database records have the lastModifiedBy field filled in correctly. However, when we go to production – userName is an empty string!
UPDATE & CLARIFICATION
I should have included this yesterday –
in web.config we have
we do not want to impersonate the user b/c they will not have access to the backend system (Microsoft CRM) but the service account does.
Inside IIS we have anonymous access turned off and Windows Integrated Security turned on. The application is running in its own Virtual Directory and has an application and app pool assigned to it.
Overall the stuff appears the same as our staging server. I know diagnosing this via a short post on stack overflow is a PITA, but I’m grasping for staws at this point. I know this is something really lame like a checkbox I forgot to click or a minor little setting that usually doesnt matter.
Anyway, I apperciate any suggestions that come my way.
Have you switched off Anonymous Access to the web app?