ASP.NET: HttpContext.Current.User.Identity.Name Shows Old Username

Problem:

IIS Log shows the new username, .NET shows old username. The issue only occurs with Server 2008 R2. In my environment, Server 2003 works fine.


Solution: Reboot. Ongoing, you probably want to update the registry on the server to refresh the AD cache more frequently with the following settings:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa
DWORD: LsaLookupCacheExpireTime = 1440 
DWORD: LsaLookupCacheMaxSize = 128
DWORD: LsaLookupCacheRefreshTime = 10
Notes:
  • All values in minutes (decimal).
  • Documentation says these registry values are dynamic but my first user test did not work.
References: