You can get the current identity of the user under which the current thread is running (not necessarily the logged in user) using WindowsIdentity.GetCurrent(). Alternatively you can get the logged in user name via the Environment.UserName property. It is not guaranteed to be the user running the current process however.
In a web application, you need to invoke the following code to get the user identity of the active user on the current request:
System.Web.HttpContext.Current.User.Identity
This is a little different from the case when you are not developing web applications, because under default settings the current windows user thats running a web application on the server is the IIS user account and not the actual user account associated with a particular request.
SenthilkumarPosted May 7, 2012, 11:05 PM
Satyapriya NayakPosted May 7, 2012, 9:46 PM
Use System.Environment.UserName
Thanks