【问题标题】:Get Current Windows User VB.net获取当前 Windows 用户 VB.net
【发布时间】:2010-10-19 17:51:20
【问题描述】:

我尝试了多种方法来获取 vb.net/asp.net 中当前登录用户的用户名。我在 IIS 6 上运行它,并且知道它将为用户名返回 NETWORK SERVICE。我需要获取实际 Windows 框登录的用户名。

我尝试了以下代码:返回 NT AUTHORITY\NETWORK SERVICE

Dim User = System.Security.Principal.WindowsIdentity.GetCurrent.User
Dim UserName = User.Translate(GetType(System.Security.Principal.NTAccount)).Value

任何帮助将不胜感激。如果我不清楚,请告诉我。

【问题讨论】:

    标签: asp.net windows vb.net iis-6 ldap


    【解决方案1】:

    你应该设置

     <authentication mode="Windows" />
     <identity impersonate="true" />
    

    在Web.config 中能够做到这一点。

    【讨论】:

      猜你喜欢
      • 2023-03-31
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 2010-11-13
      • 1970-01-01
      • 1970-01-01
      • 2014-05-16
      • 2012-12-19
      相关资源
      最近更新 更多