获得Windows登录用户名ASP .NET [英] Get Windows logged-in Username ASP .net
问题描述
我在IIS上部署有8 Forms身份验证模式的应用程序。
现在有商业的地方要显示一个弹出消息,如果Windows用户和应用程序用户创建不同的审计日志的要求。
I have an application deployed on IIS 8 having forms authentication mode. Now there is a requirement where business wants to show a popup message and create an audit log if the Windows User and the Application user is different.
有关这一点,我想在用户登录应用程序了的logincontrol Windows的。我已经尝试了很多方法,但没有帮助。
For this I want to get the Windows Logged in user on logincontrol of the applicaiton. I have tried many ways but nothing is helping.
请指引我,如果有可能或没有。
Please guide me if it is possible or not.
有人家伙。请帮我...
Guys anyone.. Please help me...
推荐答案
我用这个网站作为一个参考:
I use this site as a reference:
http://richhewlett.com / 2011/02/15 /越来越-一个用户,用户名,在ASP-NET /
(如果本站转载总结下山)
(reposted summary in case site goes down)
方案1:匿名身份验证在IIS与模拟关闭。
Scenario 1: Anonymous Authentication in IIS with impersonation off.
HttpContext.Current.Request.LogonUserIdentity.Name COMPUTER1\IUSR_COMPUTER1
HttpContext.Current.Request.IsAuthenticated False
HttpContext.Current.User.Identity.Name -
System.Environment.UserName ASPNET
Security.Principal.WindowsIdentity.GetCurrent().Name COMPUTER1\ASPNET
方案2:Windows身份验证在IIS中,模拟了。
Scenario 2: Windows Authentication in IIS, impersonation off.
HttpContext.Current.Request.LogonUserIdentity.Name MYDOMAIN\USER1
HttpContext.Current.Request.IsAuthenticated True
HttpContext.Current.User.Identity.Name MYDOMAIN\USER1
System.Environment.UserName ASPNET
Security.Principal.WindowsIdentity.GetCurrent().Name COMPUTER1\ASPNET
场景3:匿名身份验证在IIS中,在模拟
Scenario 3: Anonymous Authentication in IIS, impersonation on
HttpContext.Current.Request.LogonUserIdentity.Name COMPUTER1\IUSR_COMPUTER1
HttpContext.Current.Request.IsAuthenticated False
HttpContext.Current.User.Identity.Name -
System.Environment.UserName IUSR_COMPUTER1
Security.Principal.WindowsIdentity.GetCurrent().Name COMPUTER1\IUSR_COMPUTER1
方案4:Windows身份验证在IIS中,在模拟
Scenario 4: Windows Authentication in IIS, impersonation on
HttpContext.Current.Request.LogonUserIdentity.Name MYDOMAIN\USER1
HttpContext.Current.Request.IsAuthenticated True
HttpContext.Current.User.Identity.Name MYDOMAIN\USER1
System.Environment.UserName USER1
Security.Principal.WindowsIdentity.GetCurrent().Name MYDOMAIN\USER1
这篇关于获得Windows登录用户名ASP .NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!