ruby-net-ldap icon indicating copy to clipboard operation
ruby-net-ldap copied to clipboard

No way to specify connection's LdapVersion?

Open renier opened this issue 9 years ago • 3 comments

If you do an ldap search on a server that only supports ldap version 2, you get an error from the server, since net-ldap is using version 3 by default with no visible way of changing it.

If I force-change the version used by Net::LDAP::Connection::LdapVersion to 2 with:

class Net::LDAP::Connection
  LdapVersion = 2
end

Then ldap search works (authenticated bind also works), but you get a warning from ruby saying that you have modified a constant.

Is there a better way to change the connection's ldap version? I've looked at the docs and the code, but have not found it. Thanks.

renier avatar Sep 22 '14 23:09 renier

Looks hardcoded here: https://github.com/ruby-ldap/ruby-net-ldap/blob/78c159b3ea747b4316334c2032445585b2bfe7c6/lib/net/ldap.rb#L1183

If this were configurable, it would likely mean disabling specific features (like search result paging/sorting, SASL auth, etc).

If setting the constant is working for you in practice, it's going to be hard to beat in terms of practicality. Not sure if it's on the immediate roadmap to update the library to explicitly support version 2 (or configurable versions).

mtodd avatar Sep 22 '14 23:09 mtodd

@mtodd To properly support switching between versions, yes. Though, I imagine that to add a parameter for it, not all of the other work has to happen in the same commit or even the same net-ldap release. It could be experimental until all of that is in place.

renier avatar Sep 23 '14 01:09 renier

@renier just curious, what LDAP server are you connecting to that forces you to use version 2?

mtodd avatar Oct 03 '14 02:10 mtodd