Dotnet to Dotnetcore - WindowsIdentity.GetCurrent().Name

In a Dotnet program, to retrieve the name of the user that launched it, I used :


This is deprecated in DotnetCore and here is the new way way to do it :


I was afraid that the Environment was not the Current one if you use runas.exe so I checked it with a Hello {0} console app and it’s good :)

Discuss on Twitter