Share via


How can I get the Windows username from a web application??

Question

Tuesday, March 15, 2011 10:55 PM

Hello,

  I have an intranet web application. In this application, I need to get the username of the Windows user so I can place it in a record when the record get's submitted. I have searched the web and found some answers, but I am still getting nowhere. I have set up the following:

 

The server is using IIS 6.0 and the web app is using .NET 3.5.

 

I have authentication mode set to Windows and I have anonymouse access turned off. (When Anonymous Authentication is disabled, I get a pop-up asking for login credentials. If I enable it, I can into the app, but I don't get any value for my username)

 

I have tried to set impersonate to true, but that does not seem to make a difference.

 

I have also set the authorization for the application to deny users = "?"

 

In my code, I am using a label to test the output, which is:

 

labelDebug.Text = Page.User.Identity.Name;

 

The best I can get is the username of the account on the web server. I can't seem to get the username of the Windows user. All users are already authenticated by the domain, since we all log into our computers. I don't want anyone to have to log into the application itself. I know this is possible, I just think I am missing something simple.

 

So I thought I would ask the experts :) Any ideas?

 

Thanks,

  Andy

Andrew Casey

All replies (1)

Wednesday, March 16, 2011 2:11 AM ✅Answered

Hi andrewkc69,

The following links might help:

How to Get Window NT Logged User Name Using ASP.NET

How To: Use Windows Authentication in ASP.NET 2.0

May it helps~

Ouch Liu
Welcome to visit by blog: Ouch@點部落