get windows auth code
2021-07-05 01:12
标签:windows sid cat public cto ring ted window ret get windows auth code 标签:windows sid cat public cto ring ted window ret 原文地址:https://www.cnblogs.com/yafeili/p/9838116.htmlpublic static WindowsIdentityInfo GetWindowsIdentityInfo(HttpContext context)
{
WindowsIdentityInfo info = new WindowsIdentityInfo();
info.IsAuthenticated = false;
if (context==null)
{
WindowsPrincipal winPrincipal = (WindowsPrincipal)context.User;
if (winPrincipal != null)
{
info.IsAuthenticated = winPrincipal.Identity.IsAuthenticated;
info.UserName = winPrincipal.Identity.Name;
if (!string.IsNullOrEmpty(info.UserName))
{
string[] arr = info.UserName.Split(‘\\‘);
if (arr != null && arr.Length >= 2)
{
info.DisplayName = GetUserFullName(arr[0], arr[1]);
}
}
info.AuthenticationType = winPrincipal.Identity.AuthenticationType;
}
}
return info;
}
private static string GetUserFullName(string domain, string userName)
{
DirectoryEntry userEntry = new DirectoryEntry("WinNT://" + domain + "/" + userName + ",User");
return (string)userEntry.Properties["fullname"].Value;
}
上一篇:C# Base64Helper
文章标题:get windows auth code
文章链接:http://soscw.com/index.php/essay/101938.html