Question Retrieve Windows username in server application

NapstrPSX

Member
Joined
Jan 7, 2010
Messages
5
Programming Experience
1-3
So, I have been trying several different methods to retrieve the Windows username so I can write it to a log file when a user performs a certain function.

When I run my app locally, these few lines of code work:

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

System.Environment.UserName 'holds correct username

however, once i deploy the application to our intranet, when I test it instead of getting my windows logon I get something like this:

IUSR_SVR-INTRANET

Is it even possible to retrieve their username in this situation, when the app isn't local? All of the different ways I have come across to retrieve a username is enough to make my head spin. Any clarification would be greatly appreciated.
 
Thank you very much for your response, but I am going to be using another method. It involves using Request.QueryString to pull their ID from the URL... similar to how other pages on our intranet are. I just thought there would be an easier line of code to get something from the active directory.

Again, thank you though!
 
Back
Top