IIS7设置获取ASP.Net中的当前用户名

编程入门 行业动态 更新时间:2024-10-11 19:13:37
本文介绍了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中的当前用户名

本文发布于:2023-11-28 12:04:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642330.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户名   ASP   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!