获取当前Windows用户VB.net [英] Get Current Windows User VB.net
本文介绍了获取当前Windows用户VB.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图抓住当前的登录用户在vb.net/asp.net用户名的多种方式。我在IIS 6上运行它,理解它会返回网络服务的用户名。我要抓住实际的窗户框的用户名登录。
I have tried multiple ways of grabbing the username of a current logged on user in vb.net/asp.net. I am running it on IIS 6 and understand that it will return NETWORK SERVICE for the username. I need to grab the username of the actual windows box log on.
我曾尝试以下code:返回NT AUTHORITY \\ NETWORK SERVICE
I have tried the following code: Returns NT AUTHORITY\NETWORK SERVICE
Dim User = System.Security.Principal.WindowsIdentity.GetCurrent.User
Dim UserName = User.Translate(GetType(System.Security.Principal.NTAccount)).Value
任何帮助将大大AP preciated。如果我不清楚,请让我知道。
Any help will be greatly appreciated. If I am unclear please let me know.
推荐答案
您应该设置
<authentication mode="Windows" />
<identity impersonate="true" />
在的Web.config
才能够做到这一点。
这篇关于获取当前Windows用户VB.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文