gpt4 book ai didi

.net - Asp.NET 主体 WebORB HttpHandler

转载 作者:行者123 更新时间:2023-12-01 05:46:18 25 4
gpt4 key购买 nike

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

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?把它放在一个 session 对象中?你能改变 HttpContext.Current.User.Identity ?不应该 HttpContext.Current.User.IdentityThread.CurrentPrincipal.Identity.Name 相同?

ps:用户不在事件目录中。

最佳答案

关于.net - Asp.NET 主体 WebORB HttpHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1827911/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com