更新时间:2023-02-17 12:20:47
***的方法是使用 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:
Microsoft.Windows.Compatibility
NuGet 包.Novell.Directory.Ldap.NETStandard
.在这个问题上有两个答案描述了如何实施这两种解决方案.
There are two answers on this question that describe how to implement both solutions.