I’m trying to find out current user name for my sharepoint application. There are more that one way how to do this. However the sharepoint way returns misleading value.
System.Security.Principal.WindowsIdentity.GetCurrent().Name // returns MY_COMPUTER\\my_user HttpContext.Current.User.Identity.Name // returns MY_COMPUTER\\my_user HttpContext.Current.Request.ServerVariables['AUTH_USER'] // returns MY_COMPUTER\\my_user Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.LoginName // returns SHAREPOINT\\system
What is the cause of this behavior? Will I encounter problems if I’ll use non-sharepoint way?
This is expected if the user is the application pool account running the current web application.
BTW, it’s supposed to be the same name as displayed in the welcome control (upper left control)