Search code examples
asp.netvb.netwindowshttpcontext

What is the equivalent of the 'HttpContext.Current.User.Identity' for a Windows application?


I believe HttpContext cannot be used for Windows application according to my research. I want to use an equivalent of HttpContext for my Windows application to implement something like this, for example:

Dim userName = HttpContext.Current.User.Identity.Name

Solution

  • Environment.Username should do the trick for the currently logged in user, WindowsIdentity.GetCurrent() will get the user for the application's thread.