devise_ldap_authenticatable
devise_ldap_authenticatable copied to clipboard
Devise::LDAP::Adapter.get_ldap_param(self.username,"mail") returns Net::BER::BerIdentifiedArray
I'm using this gem to connect to Active Record 2012 and i was getting and error on this portion of code
before_validation :get_ldap_email
def get_ldap_email
self.email = Devise::LDAP::Adapter.get_ldap_param(self.username, 'mail')
end
The Devise::LDAP::Adapter.get_ldap_param(self.username, 'mail')
returns a Net::BER::BerIdentifiedArray
and crashes when calling to_s
(Called somewhere internally).
My workarround is this:
before_validation:get_ldap_email
def get_ldap_email
array = Devise::LDAP::Adapter.get_ldap_param(self.username, 'mail')
self.email = array.first
end
But i'm reporting this because i don't know if it should work like this, but it is not working the way the documentation says it should.
My guess is Net::LDAP changed the way their search method works. Looking through their documentation (http://net-ldap.rubyforge.org/Net/LDAP.html#method-i-search), I see that the search method returns an array. Should be a simple fix within devise_ldap_authenticatable
Yup, your workaround works. Just beware of the typo in "arrray"! BTW: I still ran into this...
lol "arrray" i never noticed it until now :sweat_smile: