Asp.NET主要WebORB HttpHandler

时间:2009-12-01 18:19:13

标签: .net asp.net authentication weborb iprincipal

我有一个Flex-WebORB-Asp.NET应用程序。登录时,有一个AuthenticationHandler实现了一个WebORB接口:

IPrincipal CheckCredentials(string username, string password, Request message);

所以我创建一个Principal并返回它。 WebORB使用Principal检查远程方法调用的身份验证和授权。

var principal = new GenericPrincipal(new GenericIdentity(user.id.ToString()), new[] { "admin" });
return principal

现在,在这一点上,如果我检查HttpContext.Current.User.Identity是什么,那就是WindowsIdentity。

到目前为止一切顺利。稍后,通过WebORB进行远程调用,我通过调用以下方式获取登录用户的ID:

Thread.CurrentPrincipal.Identity.Name

所以我猜WebORB确保每次远程调用都会设置线程的身份。

问题是,当我调用HttpHandler(检索图像)时,我也尝试使用Thread.CurrentPrincipal.Identity.Name获取登录用户的ID,但这不起作用。可能是因为使用HttpHandler,WebORB不起作用。

你如何解决这个问题,以便在两种情况下都能以相同的方式获取登录用户的ID?把它放在会话对象中?你能改变HttpContext.Current.User.Identity吗? HttpContext.Current.User.Identity不应与Thread.CurrentPrincipal.Identity.Name相同吗?

ps:用户不在Active Directory中。

1 个答案:

答案 0 :(得分:1)