Solved

Retrieve System User Name In ASP.Net

Posted on 2004-10-18
6
1,269 Views
Last Modified: 2008-01-09
I have an application where the "Creator:" field needs to be populated from a dropdown list of names. I need to retrieve the UserName from the system, but it comes back as is ASPNET. Is there a way I can get the page to retrieve the login name used to logon on to the computer.
Thanks
0
Comment
Question by:name43
6 Comments
 
LVL 18

Accepted Solution

by:
tusharashah earned 125 total points
ID: 12337698
Make sure you have done following things:

  - Disable Annonymous Access (from IIS)
  - Turn on Windows Authentication (in Web.Config)  (<authentication mode="Windows" />)
  - Use 'User.Identity.Name' or Request.ServerVariables("LOGON_USER") or Request.ServerVariables("REMOTE_USER") to retrive Username

-tushar

0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12337705
Hi name43,

first of all you have remove anonimous access to the virtual directory
second, the user name can be got like HttpContext.Current.User.Name

Regards!
B..M
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12337708
tusharashah,

sorry, there was nothing when i've started to write

B..M
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 22

Expert Comment

by:CJ_S
ID: 12337709
There is a differenence between the username on the computer and the username used to log on to the system. When you are on an intranet you can use Windows Integrated Logon. This means that, with correct settings on the client, that the current logon information is used to log on to the website. When Anonymous access is disabled the website will require you to log on with a username and password combination that is recognized on the domainname (also specified on the server).

With anonymous access enabled there is a big chance that you will not get the current username from the client. You can try to read out the servervariables properties LOGON_USER or AUTH_USER, but those will return you the ASPNET user (like you have right now).
Without adjusting the client and serverside settings to enable windows authentication the only thing you can do is add an ActiveX control which is loaded on the client to read the current username and insert that into a hidden field.

Did this information solve your question?
0
 
LVL 1

Author Comment

by:name43
ID: 12337919
Thanks for your help, I saw this answer on many pages but could not set it up correctly, But I have done that now and can retrieve the user name used to logon on to the PC.

Thanks
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12337966
Nice to have you going name43!

B..M, I understand that happens... but that was very nice of you :)

-tushar
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now