get name of User logged into windows using asp.net web application
<p>When I use System.Environment.UserName or httpcontext.current.... etc all are returning "System" as user as my site is hosted in system privileged.
Tried WMI but this comes up as empty. </p>

<pre><code>ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
WinUser = (string)collection.Cast&lt;ManagementBaseObject&gt;().First()["UserName"];
</code></pre>

<p>I am using Basic Authentication and Anonymous authentication is turned off.
any idea?</p>
