【发布时间】:2023-03-31 19:58:01
【问题描述】:
在全新的 ASP.Net Core 应用程序中,您可以选择“Windows 身份验证”,当您启动应用程序时,您会直接拥有 Windows 用户,并且可以在控制器中使用 User.Identity。
我想在 PiranhaCMS MVC V10.0.0 应用程序中获取 Windows 用户(如果可能,通过询问用户凭据,否则自动)并将其存储在 Piranha 用户/身份表中。
我尝试将 windowsAuthentication 设置为 true(在 launchSettings.json 中)并将其添加到 Startup.cs 中:
services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate();
services.AddAuthorization(options => {
options.FallbackPolicy = options.DefaultPolicy;
});
但 User.Identity.Name 在控制器中仍然为空(直到我使用默认管理员用户登录管理器)。
如何通过询问其(Windows 或 AD)凭据来获取当前 Windows 用户?
【问题讨论】:
标签: c# asp.net-core piranha-cms