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

查看:152
本文介绍了无法使用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.

因此,仅因为该属性在说值是假的,它在必要时才使用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天全站免登陆