问题
I have encounter the following issue while deploying my application into a WebServer,
The code that i have was "Usercheck = My.User.Name" but that will return the Service Account for the instance that is running my webapp, so i need to display "evilla" which is my current windows credential, when i try to connect for the first time to the webapp it asks for my network credentials.
Is it possible to grab my windows username and not the service account?? (i'm conecting remotely to the app)
i have tried:
'Usercheck = Request.LogonUserIdentity.Name
Usercheck = HttpContext.Current.Request.LogonUserIdentity.Name
TextBox4_AddDataControl.Text = Usercheck
TextBox6_AddDataControl.Text = Environment.UserName
Am i missing something??
Note: i'm getting from the above code "NA/SRS-SA" (service account)
Thank you!!
回答1:
After more research, the below code returned the user that is logged at the time in the service account.
TextBox6_AddDataControl1.Text = Request.ServerVariables("LOGON_USER")
Hope it helps someone in the future! :)
来源:https://stackoverflow.com/questions/15280402/get-client-user-name-from-a-web-application-running-in-a-web-server-with-windows