越来越域\\用户名的Web应用程序在Intranet无需登录 [英] getting domain\username for web app on intranet without logging in
问题描述
我对我们的内联网(VS 2005)的Web应用程序。有不要求用户几页来登录到应用程式(反馈和默认页)。我试图让域和用户名,以显示和/或反馈发送。有没有办法做到这一点,而无需登录用户?我试过 this.Request.ServerVariables [LOGON_USER]
和 this.User.Identity.Name
,但他们都没有工作。
I have a web app on our intranet (VS 2005). There are a couple pages that don't require the user to be logged into the app (feedback and the default page). I am trying to get the domain and username to display and/or send with the feedback. Is there a way to do this without requiring the user to log in? I've tried this.Request.ServerVariables["LOGON_USER"]
and this.User.Identity.Name
, but neither of them worked.
编辑:结果
我应该提到大多数用户有Windows 2000在他们的机器。它的工作原理我的开发机(XP)上,但不是在生产网络(在那里我有2000年)。
I should have mentioned most of the users have Windows 2000 on their machines. It works on my development machine (XP), but not on the production network (where I have 2000).
推荐答案
特里萨,我认为这是你在找什么...
Theresa, I think this is what you're looking for...
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
WindowsIdentity identity = (WindowsIdentity)principal.Identity;
String userName= principal.Identity.Name;
这篇关于越来越域\\用户名的Web应用程序在Intranet无需登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!