Hi, trying to get the username of the user logged into a computer but it doesn't appear to be working. I was using Label1.Text = User.Identity.Name; to check if it did work but it wasn't displaying anything. The only reason I need the username is to send it through to an SQL stored procedure to keep track of who is downloading reports that are being generated, this system will be an internal system for a company. Any help with this would be great, thank you.

Recommended Answers

All 3 Replies

Are you storing the logged in user's user name anywhere? In a session variable for instance?
Withoutknowing what you are doing to persist the user name after a successful login there isn't much advice we can give.
For example, User.Identity.Name doesn't get populated with a value without you making it so.

The user doesn't have to log in to the system. I'm trying to get the username they use to log on to the computer. Not sure if this can be done or not.

For you to get that information using User.Identity.Name, the website needs to be configured (in IIS) by enabling Windows Authentication and disabling anonymous authentication. With that action, you will get the logged on userid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.