Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network credentials of current user?

Status
Not open for further replies.

josephk73

Technical User
Aug 1, 2002
115
GB
Hi Guys,

I have a web page that I need to improve so that the page automatically displays the username of the person accessing the web page in a label.

This would be used to speed up text entry, instead of the user having to enter his/her name into a text box.

How easy is this to do?

Can anybody supply an example?

Somebody told me to try HttpContext object, but this is not working for me.

Any help would be great.
 
It depends on how the user is authenticating onto the system.. ie SqlServer, AD..etc.
 
I don't know if this helps or not but I am using Forms Authentication so when the user logs in the user name is captured.

I have a label that says "Welcome "username"".
In my code I used Name.Text = My.User.Name or captured it in a session variable.
 
Anonymous connections (most web pages without a login form)
- returns the IUSR account of the web server and does you no good

Forms Authentication
- returns the user name that a user has entered into a login form
- from an aspx codebehind file
- lblUser.Text = User.Identity.Name
- from a MasterPage
- lblUser.Text = Context.User.Identity.Name

Windows Authentication
- returns the domain\username of the logged in user of that computer (only works for IntrAnet/ExtrAnet)
- from an aspx codebehind file
- System.Security.Principal.WindowsIdentity userNm = System.Security.Principal.WindowsIdentity.GetCurrent();
- lblUser.Text = userNm.Name;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top