Get Client User Name from a Web Application running in a Web Server with Windows Auth Enabled & Service Account

StackOverflow https://stackoverflow.com/questions/15280402

Question

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!!

Was it helpful?

Solution

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! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top