IIS7设置获取ASP.Net中的当前用户名 [英] IIS7 Setting to get Current User Name in ASP.Net

查看:156
本文介绍了IIS7设置获取ASP.Net中的当前用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team,



我想要当前窗口用户ID。

我有以下内容:

IIS:IIS7

应用程序池:

 ASP.NET v4.0 





我试过以下代码 -



 Win_Login_ID = Environment.UserName; 
Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();
Win_Login_ID = WindowsIdentity.GetCurrent()。Name.ToString();
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
Win_Login_ID = p.Identity.Name.ToString();
Win_Login_ID = Request.ServerVariables [ 5 ]。ToString();
Win_Login_ID = Page.User.Identity.Name.ToString();





这是在本地PC上运行但是 - 用户当我在Intranet上/从IIS运行时,名称没有得到 - 浏览* .80(Http)链接从IIS



请帮助...... !!!



编辑:来自OP-comment的其他问题

我在IIS中需要做什么设置??? div class =h2_lin>解决方案

确保打开Windows身份验证并禁用匿名身份验证。


我试过



{

Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();



开启Windows身份验证,和;



禁用匿名身份验证。;

}



在IIS7 + Windows服务器2008R2中运行正常:)



谢谢堆!


Hello Team,

I want current window User ID.
I have below :
IIS : IIS7
Application Pool :

ASP.NET v4.0



I have tried following codes -

Win_Login_ID = Environment.UserName;
        Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();
        Win_Login_ID = WindowsIdentity.GetCurrent().Name.ToString();
        System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
        Win_Login_ID = p.Identity.Name.ToString();
        Win_Login_ID = Request.ServerVariables[5].ToString();
        Win_Login_ID = Page.User.Identity.Name.ToString();



This is running on local PC but - user Name is not getting when I run it on Intranet / from IIS - Browse *.80(Http) link fron IIS

Please help...!!!

Edit: Additional question from OP-comment
What setting I need to do in my IIS???

解决方案

Make sure Windows Authentication is turned on and disable anonymous authentication.


I tried

{
Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();

turn on Windows Authentication, and;

disable anonymous authentication.;
}

in IIS7 + windows server 2008R2 and works fine now :)

Thanks heaps!


这篇关于IIS7设置获取ASP.Net中的当前用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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