ruby-ldap / ruby-net-ldap

Pure Ruby LDAP library
https://rubygems.org/gems/net-ldap
Other
400 stars 253 forks source link

No way to specify connection's LdapVersion? #112

Open renier opened 10 years ago

renier commented 10 years ago

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.

mtodd commented 10 years ago

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).

renier commented 10 years ago

@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.

mtodd commented 10 years ago

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