Review the code snippet before inserting it on your project.
System.Security.Principal.WindowsPrincipal wprincipal = ((System.Security.Principal.WindowsPrincipal)System.Threading.Thread.CurrentPrincipal); string sUserID = wprincipal.Identity.Name.ToString();
With from Barcelona