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

孤街醉人 提交于 2019-12-14 04:21:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!