从asp.net的Windows登录获取用户
问题描述:
我有一个内部网站,我需要查看谁登录到Windows PC,以便他们不需要自己键入他们的名称。从asp.net的Windows登录获取用户
我曾尝试:
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
和
string strName = HttpContext.Current.User.Identity.Name.ToString();
它工作在我的电脑上,但是当我用它在服务器上没有。
答
使用try <authentication mode="Windows"/>
答
两件事情你应该照顾:
- 在web.config:`
- 要获取当前用户,使用此:
System.Security.Principal.IPrincipal User = System.Web.HttpContext.Current.User;
,如果你需要什么更多的PLZ问
答
帮我:
<system.web>
<anonymousIdentification enabled="false"/>
</system.web>
我能得到用户的喜欢这个很简单:
HttpContext.User
什么身份验证模式是您使用来识别用户? – SeanCocteau 2012-02-22 12:55:26