越来越域\\用户名的Web应用程序在Intranet无需登录 [英] getting domain\username for web app on intranet without logging in

查看:166
本文介绍了越来越域\\用户名的Web应用程序在Intranet无需登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我们的内联网(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屋!

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