要将Asp.Net Core的HTTP.SYS Windows身份验证回退到NTLM而不是Kerberos,您可以在应用程序的Startup.cs文件中使用以下代码示例:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace YourNamespace
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// 添加身份验证服务
services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);
// 其他服务配置...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
// 使用身份验证中间件
app.UseAuthentication();
// 其他中间件配置...
}
}
}
这段代码配置了Asp.Net Core应用程序的身份验证服务和中间件。通过使用services.AddAuthentication
方法,我们将身份验证方案设置为Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme
,这将使用Windows身份验证。
然后,我们在Configure
方法中使用app.UseAuthentication
方法将身份验证中间件添加到应用程序的请求处理管道中。
请注意,您还需要在应用程序的项目文件中添加对Microsoft.AspNetCore.Server.IISIntegration NuGet包的引用。
此配置将使HTTP.SYS回退到NTLM身份验证,而不是Kerberos。