Try using:
System.Security.Principal.WindowsIdentity.GetCurrent().Name This should return the current user account and name.
If this does not work after changing the username, another method is to get the current SID of the user, and then find the username corresponding to this SID.
using System.Security.Principal; string sid = WindowsIdentity.GetCurrent().Owner.ToString(); return new SecurityIdentifier(sid).Translate(typeof(NTAccount)).ToString();
Otherwise, take the SID and try to find the appropriate user either through WMI or through the registry. Instructions on how to do this manually are here: http://pcsupport.about.com/od/registry/ht/find-user-security-identifier.htm
If you can manually confirm that any of these methods returns a new username, then simply implements this in code using WMI calls or registry access.
source share