【问题标题】:Is Windows Authentication Impersonation dead in ASP.NET Core?ASP.NET Core 中的 Windows 身份验证模拟是否已死?
【发布时间】:2020-04-09 21:57:13
【问题描述】:

在试图找出为什么所有的模仿都不起作用时发现了这一点。

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.1&tabs=visual-studio#impersonation

ASP.NET Core 不实现模拟。

RunImpersonated 不支持异步操作并且不应该 用于复杂场景。例如,包装整个请求 或中间件链不受支持或推荐。

这听起来对我来说是不可行的。以最终用户身份查询数据库是否不再实用?

【问题讨论】:

    标签: asp.net-core


    【解决方案1】:

    .NET 5 开始会有一个WindowsIdentity.RunImpersonatedAsync

    现在,你必须坚持这个 (remarks from the 3.1 docs):

    与 Impersonate 不同,此方法可以可靠地与 async/await 模式一起使用。在异步方法中,此方法可以与异步委托参数一起使用,以便可以等待生成的任务。

    System.Security.Principal.WindowsIdentity5.0.NET Platform Extensionscurrently in preview2
    你可以在这里找到发布日期:Upcoming Ship Dates

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 2019-01-04
      • 1970-01-01
      • 2011-11-21
      • 2014-09-08
      • 2016-07-14
      相关资源
      最近更新 更多