Link to home
Start Free TrialLog in
Avatar of name43
name43

asked on

Retrieve System User Name In ASP.Net

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
ASKER CERTIFIED SOLUTION
Avatar of tusharashah
tusharashah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmarinov
mmarinov

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
tusharashah,

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

B..M
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?
Avatar of name43

ASKER

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
Nice to have you going name43!

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

-tushar