我有一个 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(检索图像)时,我还尝试使用 获取登录用户的 id Thread.CurrentPrincipal.Identity.Name
,但这不起作用。可能是因为使用 HttpHandler,WebORB 不会起作用。
您将如何解决这个问题,以便我可以在两种情况下以相同的方式获取登录用户的 ID?把它放在一个会话对象中?你能改变HttpContext.Current.User.Identity
吗?不应该HttpContext.Current.User.Identity
和 一样Thread.CurrentPrincipal.Identity.Name
吗?
ps:用户不在活动目录中。