.NET framework
Naming space provides a method of accessing security information, including the identity of the current user. To obtain the current username, you can use the class, as shown below: System.Security.Principal
WindowsIdentity
code:
Explanation:
<code class="language-csharp">string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;</code>
Use the method to obtain the current Windows identity.
Access TheWindowsIdentity.GetCurrent()
WindowsIdentity
Name
The above is the detailed content of How to Get the Current Username in C# .NET?. For more information, please follow other related articles on the PHP Chinese website!