Get Client User Name from a Web Application runnin

2019-08-02 08:59发布

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条回答
迷人小祖宗
2楼-- · 2019-08-02 09:42

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

查看更多
登录 后发表回答