gpt4 book ai didi

docker - Linux Hosting和.NET Core Docker:PlatformNotSupportedException:此平台不支持System.DirectoryServices.AccountManagement

转载 作者:行者123 更新时间:2023-12-02 20:03:43 25 4
gpt4 key购买 nike

我在.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 is not supported on this platform.



如何使它正常工作?

谢谢!

最佳答案

我不认为您可以自动执行操作,因为那里有异常(exception),说 Activity 目录API在Linux中不可用。解决方法是构建Windows Docker容器或Windows服务

关于docker - Linux Hosting和.NET Core Docker:PlatformNotSupportedException:此平台不支持System.DirectoryServices.AccountManagement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51665676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com