Solved

Retrieve System User Name In ASP.Net

Posted on 2004-10-18
6
1,274 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn on intranet settings 1 57
Output Caching in IIS 2 30
ASP.NET gridview select textbox on focus 2 37
imap mails 1 23
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

809 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