C#获取本机域名账号

                //获取本机域账号的几种方式
                System.Security.Principal.WindowsIdentity currentUser = System.Security.Principal.WindowsIdentity.GetCurrent();
                string strUserName = currentUser.Name.ToString();
                ViewData["currentUser"] = strUserName;
                string a = HttpContext.GetServerVariable("LOGON_USER");
                ViewData["a"] = a;
                string b = HttpContext.GetServerVariable("Remote_Host");
                ViewData["b"] = b;
                string c = User.Identity.Name;
                ViewData["c"] = c;

 

posted @ 2023-05-05 15:44  妖狐鬼魅  阅读(235)  评论(0编辑  收藏  举报