[英]how to find user full name in domain from service running with system account in c#
[英]C# - Windows authentication - How to get from HttpContext user's Full doMain name (FQDN)
假設有Active Directory域:“ chiled.root.f1dm.com ”
Netbios名稱:“ CHILED1F1 ”
鑒於此代碼:
if (HttpContext.Current == null || HttpContext.Current.User == null ||
!HttpContext.Current.User.Identity.IsAuthenticated)
{
throw new MyException(WRONG_USERNAME_OR_PASSWORD_ERROR_CODE, WRONG_USERNAME_OR_PASSWORD_ERROR_MESSAGE);
}
我正在尋找一種從HttpContext到達用戶的完全限定域名(FQDN)的方法。 目前我從Netbios表單中獲取用戶域的上下文(如:CHILED1F1 \\ user_name)但我需要這個: chiled.root.f1dm.com \\ user_name
我有辦法做到嗎? 我只需要Windows當前用戶(因此機器的域名對我沒用)。 謝謝!
如果您的用戶登錄使用AD,您可以嘗試通過ServerVariables獲取他的名字。 例:
string username = Request.ServerVariables["AUTH_USER"].ToString();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.