Hi danlpez07,
Refer the below code.
you need to import the namespace System.Management by adding the reference in the project.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
string username = (string)collection.Cast<ManagementBaseObject>().First()["UserName"];
// Or
string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Also refer the below link.
Get username in c# that also works in IIS