Asp.Net日志,IIS,获得当前用户 [英] Asp.Net logging, IIS, getting current user

查看:187
本文介绍了Asp.Net日志,IIS,获得当前用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些重大问题的时候,它会得到帐户的当前用户名使用Asp.Net的缺省日志记录系统,并签署
WebSecurity.Login(model.UserName,model.Password,persistCookie:model.RememberMe)似乎正常工作。

I am having some major issues when it comes to getting the current username of the account signed on using Asp.Net's default logging system and WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe) seems to work correctly.

问题是一个非问题在本地调试时,但现在我在哪里,我部署到IIS的一个点。我已经测试了几种方法来获取登录的用户,但无济于事。我曾尝试是:

The problem is a non-issue when debugging locally, but now I am at a point where I am deploying to IIS. I have tested several ways to get the logged in user, but to no avail. What I have tried are:

 System.Web.HttpContext.Current.User.Identity.Name
 System.Security.Principal.WindowsIdentity.GetCurrent().Name
 System.Environment.UserName
 HttpContext.Current.Request.LogonUserIdentity.Name
 WebSecurity.CurrentUserName

使用结果 -

CORP \\ BSMITH

CORP\bsmith

IIS APPPOOL \\ SecondaryAppTest

IIS APPPOOL\SecondaryAppTest

SecondaryAppTest

SecondaryAppTest

CORP \\ BSMITH

CORP\bsmith

CORP \\ BSMITH

CORP\bsmith

这些都不是成功的登录用户名个人用户名aaa@gmail.com

None of these are the username of the successful logged in individual username "aaa@gmail.com"

我也更新我的web.config设置模拟为false,认证方式为形式,以及窗户。

I have also updated my web.config to set impersonation to false and authentication mode to forms as well as windows.

谁能告诉我怎么去正确的用户名,只要成功登录时部署到IIS?

Can anyone tell me how to get the correct username, provided a successful login when deployed to IIS?

非常感谢你。

推荐答案

如果您部署IIS和您配置的webconfig <身份验证模式=窗口/> 你会得到计算机名称。
但是,如果你在应用程序中设置的匿名访问以禁止,只集成Windows身份验证在IIS
你得到的用户帐户运行asp.net
如果您添加<身份冒充=真/> 我觉得你得到的窗口帐户名
我读了某个地方只是不记得是后。

if you deploy on iis and you config the webconfig <authentication mode="Windows"/> you will get the computer name. But if you set in your application a Anonymous access to disabled and only Integrated Windows Authentication in IIS you get user account run the asp.net and if you add <identity impersonate ="true"/> i think you get the window account name i read it somewhere just dont remember where is the post.

这篇关于Asp.Net日志,IIS,获得当前用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆