我正在使用 C# ASP.NET Core (MVC 6)
连接到本地的 Active Directory
。我可以通过以下方式简单地获取当前用户的 用户名
:
public MyModel(IHttpContextAccessor httpContextAccessor)
{
string userName = httpContextAccessor.HttpContext.User.Identity.Name;
}
我得到了"DOMAIN\jsmith",但我需要获取显示名称
,即"John Smith"。我该怎么做?
更新:经过更多的挖掘,目前似乎还没有这个功能:https://github.com/dotnet/corefx/issues/2089