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

uninitialized constant Net::LDAP::DN ('require net/ldap/dn' missing in lib/net/ldap.rb)

Open hbog opened this issue 9 years ago • 4 comments

Currently, an explicit "require 'net/ldap/rb'" is needed if one wants to use the Net::LDAP::DN class, because 'require net/ldap/dn' is missing in lib/net/ldap.rb

For example:

require 'net/ldap' => true Net::LDAP::DN NameError: uninitialized constant Net::LDAP::DN from (pry):2:in `pry'

require 'net/ldap/dn' => true Net::LDAP::DN => Net::LDAP::DN

hbog avatar Oct 31 '14 10:10 hbog

This was discussed previously in https://github.com/ruby-ldap/ruby-net-ldap/issues/127. At the time, I decided to not include the change, but I think we should make one of two decisions here:

  1. Deprecate and remove Net::LDAP::DN
  2. Always require 'net/ldap/dn'

I personally don't use Net::LDAP::DN, but if it's useful for other people, I feel we should go with the latter option. It's silly to skip one require for the sake of performance. On the other hand, if it's just an artifact of the past, and not something we want to support in the public API, let's nuke it.

cc @schaary @mtodd for comments.

jch avatar Oct 31 '14 20:10 jch

My use case is constructing a DN with the right characters escaped upon creation of a new LDAP entry. In my opinion, the library should provide a method to explicitly construct a valid (escaped) DN. Implicit escaping/unescaping is convenient, but the DN is actually a key to the LDAP entry and it should be unambiguous.

hbog avatar Nov 02 '14 10:11 hbog

Generally, I prefer to require essential dependencies and leave non-essential utilities as optional. In this case, Net::LDAP::DN is not essential to the normal function of Net::LDAP operations, searching, modifying, etc, but it is a useful utility for some users.

It's silly to skip one require for the sake of performance.

It's easy to look at it this way, but it's also irresponsible to disregard constraints of production environment by loading everything by default when it isn't necessary for critical function.

I think a better use of our time would be figuring out how to make Net::LDAP::DN a critical part of normal function, but I don't feel it's a high priority.

mtodd avatar Nov 12 '14 23:11 mtodd

How am I supposed to escape/sanitize special characters without Net::LDAP::DN.escape() ?

rmuktader avatar Dec 27 '18 16:12 rmuktader