Commit a0a33c64e55882603aa44e3cb9398c03db6e00fd

Authored by Arthur Esposte
1 parent be877df5

Change LDAP plugin to return all user attributes from a LDAP connection

plugins/ldap/lib/ldap_authentication.rb
... ... @@ -77,18 +77,20 @@ class LdapAuthentication
77 77 end
78 78  
79 79 def get_user_attributes_from_ldap_entry(entry)
80   - {
81   - :dn => entry.dn,
82   - :fullname => LdapAuthentication.get_attr(entry, self.attr_fullname),
83   - :mail => LdapAuthentication.get_attr(entry, self.attr_mail),
84   - }
  80 + attributes = entry.instance_values["myhash"]
  81 +
  82 + attributes[:dn] = entry.dn
  83 + attributes[:fullname] = LdapAuthentication.get_attr(entry, self.attr_fullname)
  84 + attributes[:mail] = LdapAuthentication.get_attr(entry, self.attr_mail)
  85 +
  86 + attributes
85 87 end
86 88  
87 89 # Return the attributes needed for the LDAP search. It will only
88 90 # include the user attributes if on-the-fly registration is enabled
89 91 def search_attributes
90 92 if onthefly_register?
91   - ['dn', self.attr_fullname, self.attr_mail]
  93 + nil
92 94 else
93 95 ['dn']
94 96 end
... ... @@ -111,6 +113,7 @@ class LdapAuthentication
111 113 end
112 114 login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
113 115 object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
  116 +
114 117 attrs = {}
115 118  
116 119 search_filter = object_filter & login_filter
... ...
plugins/ldap/lib/ldap_plugin.rb
... ... @@ -60,7 +60,7 @@ class LdapPlugin < Noosfero::Plugin
60 60 user.password = password
61 61 user.password_confirmation = password
62 62 person_data = plugins.dispatch(:ldap_plugin_set_profile_data, attrs, login, context.params)
63   - user.person_data = person_data.nil? ? context.params[:profile_data] : person_data
  63 + user.person_data = person_data.blank? ? context.params[:profile_data] : person_data
64 64 user.activated_at = Time.now.utc
65 65 user.activation_code = nil
66 66  
... ...