Reputation: 1
I have this application I need to get the user name and machine name of the windows logged user. I hosted this on a server. When I am tested locally this works perfectly but when I hosted on the server the program returns the server name, not the local logged user username. The user is not required to login just launch the web app.
string Machine = Environment.MachineName string UserName = Environment.UserName;
TextBox_BCAPC_Name.Text = Machine; TextBox_User_Name.Text = UserName;
From my research I may need to add some code to my webconfig or update the Authentication settings for IIS.
I am wanting to get the user name and local machine name. Without having the user login to the web form.
Upvotes: 0
Views: 1231
Reputation: 204
That is because you cannot get that information from the browser of another computer. All of your code is server-side. You would need something like a client-side script (say JavaScript) to give you that information. To do that, I would look at this post: How can I read the client's machine/computer name from the browser?
Also, it would be a major security flaw to expose the user's logged-in username. You just can't do it unless you force the user to download and install a local program that will then feed the information to you. This is really not a secure thing to do.
Upvotes: 1