【发布时间】:2018-08-03 05:09:00
【问题描述】:
我在 .NET Core 2.0 中实现了 Web api,并实现了基本身份验证和 Active Directory。我们正在使用 docker 进行部署。以下是我为 Active Directory 身份验证编写的代码:
using (PrincipalContext pContext = new PrincipalContext(ContextType.Domain, "xyz"))
{
try
{
// validate the credentials
bool isValid = pContext.ValidateCredentials(userName, password, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
if (!isValid)
{
return false;
}
}
catch(Exception)
{
return false;
}
return true;
}
为了使用 PrincipalContext,我添加了
的参考System.DirectoryServices.AccountManagement;
这完全可以在 Windows 机器上运行。使用 Docker 容器也可以在 Windows 环境中正常工作。但是我们的生产服务器是基于 Linux 的,它不能在 Linux 托管系统上运行。它显示类似的错误
PlatformNotSupportedException:此平台不支持 System.DirectoryServices.AccountManagement。
可以做些什么来让它发挥作用?
谢谢!
【问题讨论】:
标签: docker active-directory dockerfile asp.net-core-2.0 basic-authentication