无法使用 DirectoryServices.Protocols.LdapConnection 打开 SecureSocketLayer [英] Unable to turn on SecureSocketLayer with DirectoryServices.Protocols.LdapConnection

查看:23
本文介绍了无法使用 DirectoryServices.Protocols.LdapConnection 打开 SecureSocketLayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修复产品中的 SSL 错误,并注意到尽管代码将 SSL 设置为 true,但在代码的下一行中,SSL 仍然为 false.我为此编写了一个单元测试,单元测试证实了我的怀疑.

I am trying to fix a bug with SSL in a product and noticed that although the code sets SSL to be true, in the next line in the code SSL is still at false. I wrote a unit test for this and the unit test confirms my suspicions.

  [TestMethod]
  public void SecureSocketLayerSetToTrue( )
  {
     var ldapConnection = new LdapConnection( 
                                new LdapDirectoryIdentifier( "ldap.test.com", 636 ));
     ldapConnection.SessionOptions.SecureSocketLayer = true;
     Assert.IsTrue( ldapConnection.SessionOptions.SecureSocketLayer );
  }

测试失败.这里有什么我想念的吗?

The test fails. Is there something here that I am missing?

推荐答案

原来 DirectoryServices.Protocols 实现其 LDAP 调用的方式是将它们传递给低级 LDAP API.此 LDAP API 是在属性上完成获取时查询的内容.

It turns out that the way that the DirectoryServices.Protocols implements it's LDAP calls is by passing them through to a low-level LDAP API. This LDAP API is what is queried when a get is done on the property.

低级 API 仅在方法执行时更新.您可以将其视为为尚未启动的可执行文件构建命令行参数.

The low-level API is only updated when the methods are executed. You can think about this like it is building command-line arguments for an executable that hasn't been launched yet.

当调用 Bind() 时,可执行文件会启动并且属性会报告正确的值.

When a call like Bind() is made, then the executable is launched and the properties will report the correct value.

所以,只是因为该属性说该值为 false,所以它在必要时使用了 true.

So, just because the property was saying that the value was false, it was using the true when necessary.

这篇关于无法使用 DirectoryServices.Protocols.LdapConnection 打开 SecureSocketLayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆