How to determine the Windows User from a Web form Application

Platform: ASP.NET|Category: Security

Use the System.Security.Principal namespace.

VB.NET

dim wp as WindowsPrincipal  = new WindowsPrincipal(WindowsIdentity.GetCurrent())
Response.Write(wp.Identity.Name)

C#

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
Response.Write(wp.Identity.Name);