Windows 身份在用户之间变得混乱

发布于 2024-09-07 10:35:43 字数 1595 浏览 1 评论 0原文

我们在网络服务器日志中观察到一些奇怪的行为,其中当前登录用户的身份似乎正在与另一个用户交换。在进一步解释之前,我将描述我们的设置。

我们在 2 个 Windows 2008 Web 服务器上运行一个 asp.net 网站(框架的 v3.5)并使用表单身份验证。它们使用在 Linux(Cent OS 5)上运行 Apache 2.2 的单独服务器进行负载平衡。负载平衡只是将 cookie 附加到用户,并将他们定向到每个后续请求的特定服务器。

我们有时会注意到日志中的模式如下(详细信息已模糊)

第一个日志条目

用户名 - [email  ;protected]

UserId - 1111

网页 - page1

IP - ip1

时间 - 2010-06-29 12:56:20.750

SessionId - h3uyz2fsdfegugjy452sdz0far

第二个日志条目

用户名 - [电子邮件受保护]

UserId - 2222

网页 - page2

IP - ip2

时间 - 2010-06-29 12:57:16.133

SessionId - 21ipjsdfsdfieqq wyfdokgqsb55

我们是使用表单身份验证,使用标准的 ASP.NET 表单身份验证框架(标准登录控件,我们实现了自定义成员资格提供程序)。

UserName 是使用“HttpContext.Current.User.Identity.Name”检索的 Windows 身份 UserId 是在会话中设置的数据库 ID。 sessionId 是使用“HttpContext.Current.Session.SessionID”检索的,

正如您所看到的,对于 2 个不同的用户来说,相同的 Windows 身份是相同的,在不同的 IP 地址和不同的会话 ID 下,大约在同一时间访问该站点。我们检查了一下,IP 来自完全不同的位置。似乎记录了错误的 Windows 身份。 UserId 2222 应记录不同的用户名。

由于这种情况偶尔发生,因此代码是标准的,并且一段时间以来没有发生实质性变化,我们不“认为”这是一个编码错误。我们推测负载均衡器有问题或者 Web 服务器有问题。我以前从未听说过asp.net中存在此类问题。

最近,我们确实将 Windows 2003 上的 IIS6 和 Cisco 硬件负载平衡器的设置更改为 Windows 2008 上的 IIS7 和 Apache 负载平衡器的当前设置。任何想法表示赞赏。

web.config中的表单身份验证条目是

authentication mode =“Forms”

表单loginUrl =“LoginPage.aspx”name =“.ASPXFORMSAUTH”

We are observing some strange behaviour in our web server logs where where the Identity of the currently logged in user seems to be getting swapped with another user. I will describe our set up before explaining further.

We are running an asp.net web site (v3.5 of the framework) on 2 Windows 2008 web servers and use forms authentication.They are load balanced using a separate server running Apache 2.2 on Linux (Cent OS 5). The load balancing simply attaches a cookie to a user and directs them to a particular server for each subsequent request.

We notice on occasion patterns in the log like this (details obfuscated)

First Log Entry

UserName - [email protected]

UserId - 1111

WebPage - page1

IP - ip1

Time - 2010-06-29 12:56:20.750

SessionId - h3uyz2fsdfegugjy452sdz0far

Second Log Entry

UserName - [email protected]

UserId - 2222

WebPage - page2

IP - ip2

Time - 2010-06-29 12:57:16.133

SessionId - 21ipjsdfsdfieqqwyfdokgqsb55

We are using forms authentication using the standard asp.net forms authentication framework (the standard login control and we implemented a custom membership provider).

The UserName is the Windows identity retrieved using "HttpContext.Current.User.Identity.Name" The UserId is the database Id set in the session. The sessionId is retrieved using "HttpContext.Current.Session.SessionID"

As you can see the same Windows identity is the same for 2 different users, under different IP addresses and with different session id's, hitting the site about the same time. We checked and the IP's were from totally different locations. The wrong windows identity seems to be getting recorded. UserId 2222 should have a different username recorded.

Since it happens very occasionally, the code is standard and has not changed substantially for some time we don't "think" it is a coding error. We presume either a problem with the load balancer or some problem in the web server. I have never heard of such problems in asp.net before.

Recently we did change our set up from IIS6 on Windows 2003 and a Cisco hardware load balancer to the current setup of IIS7 on Windows 2008 and the Apache load balancing. Any ideas appreciated.

The forms authentication entry in the web.config is

authentication mode="Forms"

forms loginUrl="LoginPage.aspx" name=".ASPXFORMSAUTH"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦一生花开无言 2024-09-14 10:35:43

您是否设置任何会话变量?除非您在每个用户的会话中存储某些内容,否则每个请求的会话 ID 都会重置。

Are you setting any session variables? Session ID's reset for every request unless you store something, anything in session for each user.

金橙橙 2024-09-14 10:35:43

您必须保证每个用户的 cookie 都是唯一的。您不能依赖 sessionid。

You have to guarantee that each users cookie is unique. You can't depend on the sessionid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文