views:

1181

answers:

1

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.

+3  A: 

You should set

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

in Web.config to be able to do that.

Mehrdad Afshari
works exactly as need. thanks for the quick answer.
ABParsons