devise_ldap_authenticatable icon indicating copy to clipboard operation
devise_ldap_authenticatable copied to clipboard

Devise::LDAP::Adapter.get_ldap_param(self.username,"mail") returns Net::BER::BerIdentifiedArray

Open pcriv opened this issue 11 years ago • 3 comments

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.

pcriv avatar Jan 17 '14 20:01 pcriv

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

cmbankester avatar Mar 27 '14 22:03 cmbankester

Yup, your workaround works. Just beware of the typo in "arrray"! BTW: I still ran into this...

lispykid avatar Nov 21 '14 13:11 lispykid

lol "arrray" i never noticed it until now :sweat_smile:

pcriv avatar Nov 21 '14 14:11 pcriv