-->

在使用Windows身份验证启用与服务帐户在Web服务器上运行的Web应用程序获取客户端用户名(Ge

2019-10-17 19:30发布

我遇到了以下问题,同时部署我的应用程序到Web服务器,

那我的代码是“Usercheck = My.User.Name”,但将返回服务帐户运行Web应用程序我的情况,所以我需要当我尝试以显示“evilla”这是我目前的Windows凭据,连接首次到Web应用程序,它要求我的网络凭据。

是否有可能抢我的Windows用户名,而不是服务帐户? (我远程conecting到应用)

我努力了:

   'Usercheck = Request.LogonUserIdentity.Name
    Usercheck = HttpContext.Current.Request.LogonUserIdentity.Name
    TextBox4_AddDataControl.Text = Usercheck
    TextBox6_AddDataControl.Text = Environment.UserName

我这么想?

注:我从上面的代码“NA / SRS-SA”获得(服务帐户)

谢谢!!

Answer 1:

进一步的研究之后,下面的代码返回在服务帐户时登录的用户。

        TextBox6_AddDataControl1.Text = Request.ServerVariables("LOGON_USER")

希望它可以帮助别人的未来! :)



文章来源: Get Client User Name from a Web Application running in a Web Server with Windows Auth Enabled & Service Account