Last post Oct 01, 2009 12:35 AM by malcolms
Sep 30, 2009 03:28 PM|GoranPersson|LINK
If I call Environment.UserName from a Visual Studio project I get "naja01" which logged in user name. This is correct.
But if I call the same code when the project is compiled and referenced to another project (in another solution) I get "office" which is the domain.
Can someone please explain?
Sep 30, 2009 06:37 PM|sukumarraju|LINK
Use below source
//Getting the Windows NT User Name
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
String strName = p.Identity.Name;
Oct 01, 2009 12:35 AM|malcolms|LINK
You can also use the HttpContext to retrieve that and other data about the http requests.
var userName = System.Web.HttpContext.Current.User.Identity.Name;