获取Windows登录用户名ASP .net

Ati*_*ngh 3 c# asp.net iis-8

我在IIS 8上部署了一个具有表单身份验证模式的应用程序.现在有一个要求,即如果Windows用户和应用程序用户不同,企业希望显示弹出消息并创建审核日志.

为此,我想在应用程序的logincontrol上获取Windows登录用户.我尝试了很多方法但没有任何帮助.

如果可能,请指导我.

伙计们..请帮帮我......

use*_*342 15

我使用这个网站作为参考:

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
Run Code Online (Sandbox Code Playgroud)

方案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
Run Code Online (Sandbox Code Playgroud)

方案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
Run Code Online (Sandbox Code Playgroud)

方案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
Run Code Online (Sandbox Code Playgroud)