Reputation: 81
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.
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
Any help will be greatly appreciated. If I am unclear please let me know.
Upvotes: 2
Views: 8714
Reputation: 422132
You should set
<authentication mode="Windows" />
<identity impersonate="true" />
in Web.config
to be able to do that.
Upvotes: 4