I am having difficulty getting the User Name of a person logged into a machine using a windows service.
When using both System.Environment.UserName or WindowsIdentity.Ge
Windows service always runs under the credential supplied in the service Properties / Log On tab. This has nothing to do with the credentials of the person / people that are currently logged into Windows in their own sessions.
The value of NTAUTHORITY\SYSTEM is correct because your service is running under 'Local System account' credentials.
You cannot run windows service under the account of 'currently logged on' user - that's not what windows service is for.