ASP .NET - 在 Windows Server 2003(终端服务)上获取用户名?
在 Intranet ASP .NET (C#) 页面上,我尝试检索当前用户名。
从我的本地计算机(Firefox 3.5),我可以看到以下可能性的结果(来自我的本地登录):
<% Response.Write(User.Identity.Name); %>
<% Response.Write(HttpContext.Current.User.Identity.Name); %>
<% Response.Write(Page.User.Identity.Name); %>
但是,当我在本地(IE8)或服务器(IE7)上浏览时,上述任何一个都不适用于我的终端服务器登录。
这是IE和网页之间的权限问题吗?
更新1
刚刚使用 Firefox 便携版在终端服务器上测试了同一页面,它也阻止了用户名。
On a intranet ASP .NET (C#) page I am trying to retrieve the current username.
From my local machine (Firefox 3.5) I can see results (from my local login) for the following possibilities:
<% Response.Write(User.Identity.Name); %>
<% Response.Write(HttpContext.Current.User.Identity.Name); %>
<% Response.Write(Page.User.Identity.Name); %>
However when I browse locally(IE8) or on the server (IE7) none of the above work for my terminal server login.
Is this a permission issue between IE and the webpage?
UPDATE1
Just tested the same page on the Terminal Server with Firefox portable and it also blocks the username.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE - 请原谅我这个答案的模糊性,我已经很长时间没有使用它了:IE 中有一个设置可以启用用户名的传递。由于组策略的原因,该功能可能会被关闭。
大声思考...
如果站点使用本机 Windows 安全性,Firefox 通常无法工作。那么,它是否使用基于文本的登录(您实际上必须从 Firefox 中登录吗?)?这可以解释 Firefox 的工作原理。
本地浏览/服务器浏览:正常浏览(内部浏览)通常不会从代理服务器上反弹。可能是这样的情况,TS 配置为知道这一点以及为什么正确传递凭据(例如,您可以使用 IE 浏览 TS - 它有效吗?适用相同的组策略设置。)我见过所有安装流量通过代理服务器推送,然后返回到内部服务器。不幸的是,这往往会剥夺凭证,这种情况也可能发生在这里。
IIS 日志会有所帮助。您是否看到失败的 IE 流量(我认为是 403)?
IE - forgive me for the vagueness of this answer, I haven't used it in a long time: there's a setting in IE for enabling the passing of usernames. That may be off due to Group Policies.
Thinking out loud...
Firefox would normally not work if the site used native Windows security. So, is it using text-based logon (do you actually have to log on from within Firefox?)? That would explain Firefox working.
Local browsing/server browsing: Normal browsing (internal browsing) normally doesn't bounce off a proxy server. It may be the case where the TS is configured to know this and why credentials are being passed correctly (for example, can you browse through TS using IE - does it work? Same group policy settings apply.) I've seen installations where all traffic is pushed through a proxy server, then back to internal servers. Unfortunately, this tends to strip credentials and that may be happening here, too.
What will help are the IIS logs. Do you see the failed IE traffic (403'd, I think)?
嗯,您可以检查几个设置:
1) Internet 选项 >安全> (选择您的区域)>自定义级别...>>用户认证>登录>使用当前用户名和密码自动登录
和/或
2) Internet 选项 >高级>启用集成 Windows 身份验证
Hmm couple of setting you could check:
1) Internet Options > Security > (Choose your Zone) > Custom level... > User Authentication > Logon > Automatic logon with current user name and password
and/or
2) Internet Options > Advanced > Enable Integrated Windows Authentication