[英]Get Windows logged-in Username ASP .net
我在IIS 8上部署了一个具有表单身份验证模式的应用程序。 现在有一个要求,即如果Windows用户和应用程序用户不同,企业希望显示弹出消息并创建审核日志。
为此,我想在应用程序的logincontrol上获取Windows登录用户。 我尝试了很多方法但没有任何帮助。
如果可能,请指导我。
伙计们..请帮帮我......
我使用这个网站作为参考:
http://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/
(转发摘要以防案例网站出现故障)
方案1:IIS中的匿名身份验证,模拟关闭。
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:IIS中的Windows身份验证,模拟关闭。
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中的匿名身份验证,模拟
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:IIS中的Windows身份验证,模拟
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.