I'm having a requirement to identify the current logged in user in Ubuntu system. In windows I can use
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
to get the username. I'm confused how to do that for Linux. Any suggestions?
I want the current logged in user in the controller.
public ControllerName(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
webRootPath = _hostingEnvironment.WebRootPath;
var user = User.FindFirst(ClaimTypes.Name).Value;/* System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); */
}
But User is returning null always.