如何在 ASP.NET Core 中使用 Active Directory 身份验证? [英] How to use Active Directory Authentication in ASP.NET Core?

查看:27
本文介绍了如何在 ASP.NET Core 中使用 Active Directory 身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 ASP.NET Core 2.1 React SPA Microsoft 模板.

I am using the ASP.NET Core 2.1 React SPA Microsoft template.

我想使用 Active Directory 进行用户身份验证.我们的服务器使用 Active Directory 域标识在公司网络上运行.

I want to use Active Directory for user authentication. Our server runs on a corporate network using Active Directory domain identities.

我该怎么做?

推荐答案

最好的方法是使用 Windows 身份验证.但是,这只有在您运行它的服务器加入域(或受信任域)时才有效.

The best way is to use Windows authentication. However, that will only work if the server you run this on is joined to the domain (or a trusted domain).

如果没有,那么您将必须使用表单身份验证,用户输入他们的用户名和密码,然后您通过 LDAP 在代码中对 AD 进行身份验证.在 .NET Core 中有两种方法可以做到这一点:

If not, then you will have to use Forms Authentication, where the user enters their username and password, and you authenticate against AD in your code via LDAP. There are two ways to do this in .NET Core:

  1. 如果您只在 Windows 服务器上运行它,那么您可以安装和使用 Microsoft.Windows.Compatibility NuGet 包.
  2. 使用第三方Novell.Directory.Ldap.NETStandard.

这个问题上有两个答案描述了如何实施这两种解决方案.

There are two answers on this question that describe how to implement both solutions.

这篇关于如何在 ASP.NET Core 中使用 Active Directory 身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆