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

查看:505
本文介绍了如何在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).

如果没有,那么您将必须使用Forms身份验证,用户输入用户名和密码,然后您通过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

  1. If you will only run this on a Windows server, then you can install and use the Microsoft.Windows.Compatibility NuGet package.
  2. Use the third-party 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天全站免登陆