簡體   English   中英

獲取Windows登錄用戶名ASP .net

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM