【问题标题】:Request.ServerVariables("LOGON USER") returns emptyRequest.ServerVariables("LOGON USER") 返回空
【发布时间】:2012-02-28 11:41:26
【问题描述】:

Web.config 文件

<authentication mode="Windows" />     

<authorization>
  <allow users ="*" />
</authorization>

IIS 权限

(Unchecked)Enable ananymouse access
(Checked)Integrated windows authentication

C# 代码,

welcomeUser.InnerText = Request.ServerVariables.Get("LOGON USER");

显示 Windows 用户 ID 缺少什么?

【问题讨论】:

    标签: iis authentication web-config authorization windows-identity


    【解决方案1】:

    我认为变量是LOGON_USER 不是吗? (带下划线)见here

    可能会发现这会为您提供 IUSR_MachineName,因此您可能需要查找更好的方法来查找 实际登录用户,例如 User.Identity.Name 或通过使用WindowsIdentity.GetCurrent().Name;

    【讨论】:

    • 是的,问题是下划线。谢谢
    猜你喜欢
    • 2017-05-18
    • 1970-01-01
    • 2013-12-15
    • 2014-09-30
    • 1970-01-01
    • 2014-05-23
    • 2016-05-11
    • 2018-02-18
    • 2021-07-28
    相关资源
    最近更新 更多