Rails / Devise / LDAP example :: LdapAdapter.get_ldap_param

I am stuck using get_ldap_param for authentication on the eDir ldap server. I can authenticate, but when I try to read the attributes, I get nothing.

def get_ldap_email self.email = Devise::LdapAdapter.get_ldap_param(self.uid, "mail") end def get_ldap_category self.category = Devise::LdapAdapter.get_ldap_param(self.uid, "category") end 

In my ndstrace.log

 92659520 LDAP: [2011/11/14 10:10:07.401] New cleartext connection 0xe4b26c0 from 192.168.21.40:58658, monitor = 0x4b37c940, index = 8 1256683840 LDAP: [2011/11/14 10:10:07.401] DoBind on connection 0xe4b26c0 1256683840 LDAP: [2011/11/14 10:10:07.401] Bind name:cn=admin,o=xxx, version:3, authentication:simple 1256683840 LDAP: [2011/11/14 10:10:07.401] Sending operation result 0:"":"" to connection 0xe4b26c0 1310226752 LDAP: [2011/11/14 10:10:07.402] DoSearch on connection 0xe4b26c0 1310226752 LDAP: [2011/11/14 10:10:07.402] Search request: base: "cn=ntr,ou=Meta,o=xxx" scope:0 dereference:0 sizelimit:0 timelimit:0 attrsonly:0 filter: "(objectclass=*)" no attributes 1310226752 LDAP: [2011/11/14 10:10:07.402] Empty attribute list implies all user attributes 1310226752 LDAP: [2011/11/14 10:10:07.403] Sending search result entry "cn=ntr,ou=Meta,o=xxx" to connection 0xe4b26c0 1310226752 LDAP: [2011/11/14 10:10:07.403] Sending operation result 0:"":"" to connection 0xe4b26c0 1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 found connection 0xe4b26c0 socket closed, err = -5871, 0 of 0 bytes read 1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 initiating close for connection 0xe4b26c0 1251420480 LDAP: [2011/11/14 10:10:07.405] Server closing connection 0xe4b26c0, socket error = -5871 1251420480 LDAP: [2011/11/14 10:10:07.405] Connection 0xe4b26c0 closed 

The error I get after logging in:

 NoMethodError in Devise::SessionsController#create You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Rails.root: /home/ntr/Dropbox/source/devise Application Trace | Framework Trace | Full Trace Request Parameters: {"utf8"=>"✓", "authenticity_token"=>"nkuzPnh8MCK4rh/RXUErrAjVJB9ciy56hfavG60I8ck=", "user"=>{"uid"=>"ntr", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Logga in"} Show session dump Show env dump Response Headers: None 

I searched high and low for some tutorials for this on the Internet, but only found the basic implementations of the devise_ldap addon. Do not use get_ldap_param.

I would like to get some examples, tips, etc.

//Roger

+2
source share
2 answers

Dstrace shows that you get all the returned attributes:

Empty attribute list implies all user attributes

But it no longer displays the returned data in dstrace. Older eDirectories at some point showed results in a trace, but not for a long time.

Therefore, I would suggest that eDir send the data back. Now about how your application parses this answer.

+1
source

The problem, in particular, is that the devise_ldap_authenticatable gem currently does not pass the authentication password to this function.

https://github.com/cschiewek/devise_ldap_authenticatable/issues

I wish there was a callback where you could get more from the LDAP response from authentication, but this is not possible.

+1
source

Source: https://habr.com/ru/post/901560/


All Articles