Getting the Windows Login name in ASP.NET
Posted on 2007-10-02
I am running this chunk of code on my ASP.NET page:
Dim networkuser As WindowsIdentity
Dim networklogon As String
Dim arrnetworklogon As Array
Dim loginname As String
'get network user data
networkuser = WindowsIdentity.GetCurrent
networklogon = networkuser.Name 'this will return the domain\network login
arrnetworklogon = Split(networklogon, "\")
loginname = arrnetworklogon(UBound(arrnetworklogon)) 'extract the last part of the network logon
When testing the application under my local machine, it is working fine. loginname shows my windows login.
When I moved it to the production server, loginname becomes "NETWORK SERVICE". Do I need to set up anything on IIS in order to make it work?
The application I'm building is an intranet application.