简体   繁体   English

ASP.NET MVC 5 - 使用 Active Directory 进行身份验证

[英]ASP.NET MVC 5 - Identity Form Authentication with Active Directory

I am using VS Professional 2019. I create a new project with an individual authentication template.我正在使用 VS Professional 2019。我使用单独的身份验证模板创建了一个新项目。 Am I able to make some changes and make it work with Active Directory?我可以进行一些更改并使其与 Active Directory 一起使用吗? Everything I was able to find was too old and didn't work for me.我能找到的所有东西都太旧了,对我不起作用。 I would appreciate a guide on how to achieve it.我将不胜感激有关如何实现它的指南。

Try to download nuget package using Microsoft.AspNetCore.Authentication.Negotiate.尝试使用 Microsoft.AspNetCore.Authentication.Negotiate 下载 nuget 包。 Add NTLM authentication to your mvc pipeline:将 NTLM 身份验证添加到您的 mvc 管道:

services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate(NegotiateDefaults.AuthenticationScheme, op => { 
            op.Events = new NegotiateEvents();
            op.EventsType = typeof(YourClassToEnhanceAuthLogic);
});

This code adds NTLM negotiation which actually authenticates users in AD.此代码添加了 NTLM 协商,它实际上对 AD 中的用户进行了身份验证。 If you deploy to IIS, don't forget to enable windows authentication.如果您部署到 IIS,请不要忘记启用 Windows 身份验证。 It also works well with Kestrel web server.它也适用于 Kestrel Web 服务器。 You can find more on NTLM authentication here您可以在此处找到有关 NTLM 身份验证的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM