2009-04-15 196 views
2

我已经尝试了多种方法来抓取vb.net/asp.net中当前登录用户的用户名。我在IIS 6上运行它,并明白它将为用户名返回NETWORK SERVICE。我需要抓住实际的窗口框登录的用户名。获取当前Windows用户VB.net

我曾尝试下面的代码:返回NT AUTHORITY \ NETWORK SERVICE

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

任何帮助将不胜感激。如果我不清楚,请让我知道。

回答

4

您应该设置

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

Web.config才能够做到这一点。

+0

完全按照需要工作。感谢你及时的答复。 – 2009-04-15 23:40:20