我已经构建了这个函数来验证用户是否在ActiveDirectory中启用。
LdapConnection 传输的数据是加密的?
这是用user和password传输信息的安全解决方案吗?
try
{
LdapConnection connection = new LdapConnection(server);
NetworkCredential credential = new NetworkCredential(user, password);
connection.Credential = credential;
connection.Bind();
}
catch (LdapException lexc)
{
return lexc.Message;
}
catch (Exception exc)
{
return exc.Message;
}发布于 2018-03-01 02:02:35
不是默认的,不是。
Active Directory工作在几个端口上,这些端口执行相关功能:
附加信息:https://msdn.microsoft.com/en-us/library/cc875824.aspx
因此,要使它使用加密连接,您需要告诉它使用端口636或3269,然后告诉它使用SSL,如下所示:
LdapConnection connection = new LdapConnection($"{server}:636");
connection.SessionOptions.SecureSocketLayer=true;警告:根据我的经验,您在建立此连接时可能会遇到问题,因为默认情况下,域控制器使用自签名证书进行加密,而客户端计算机可能不信任该证书。如果遇到此问题,可以在计算机上安装该证书以使其可信。
但请记住,证书有两个目的:
1将始终与任何证书(甚至自我签署)发生。#2是如果证书是由不受信任的源颁发的,则连接失败的原因。
如果您确信您不需要该证书用于目的#2,那么您可以告诉它忽略与不受信任证书相关的错误,如:
connection.SessionOptions.VerifyServerCertificate =
new VerifyServerCertificateCallback((con, cer) => true);https://stackoverflow.com/questions/49033552
复制相似问题