Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the username of the user accessing ASP.NET intranet page within local network?

We have an ASP.NET intranet site, available to users who are either physically at and logged into a local machine or else to users who connect remotely via VPN. Is there a way to automatically get the username of whoever is accessing the page based on the name used to either log into the local machine or that used for the VPN?

like image 565
notnot Avatar asked Nov 30 '22 20:11

notnot


1 Answers

This is possible if you're using Windows Authentication in your pages.

You can use either Page.User.Identity.Name or the more complete System.Web.HttpContext.Current.User.Identity.Name.

Read more about it here:

Enabling Windows Authentication within an Intranet ASP.NET Web Application

If you are, however, using Forms Authentication, you'll have to keep track of the current user yourself, the most common method of which will be by storing their login name in a Session variable.

like image 131
Jon Limjap Avatar answered Jan 21 '23 03:01

Jon Limjap