问题
I am using the ASP.NET Core 2.1 React SPA Microsoft template.
I want to use Active Directory for user authentication. Our server runs on a corporate network using Active Directory domain identities.
How can I do it?
回答1:
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).
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:
- If you will only run this on a Windows server, then you can install and use the Microsoft.Windows.Compatibility NuGet package.
- Use the third-party Novell.Directory.Ldap.NETStandard.
There are two answers on this question that describe how to implement both solutions.
来源:https://stackoverflow.com/questions/53707820/how-to-use-active-directory-authentication-in-asp-net-core