~fhusson

Dotnet to Dotnetcore - WindowsIdentity.GetCurrent().Name

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

System.Security.Principal.WindowsIdentity.GetCurrent().Name

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

System.Environment.UserName

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