Commit a0a33c64e55882603aa44e3cb9398c03db6e00fd
1 parent
be877df5
Exists in
master
and in
22 other branches
Change LDAP plugin to return all user attributes from a LDAP connection
Showing
2 changed files
with
10 additions
and
7 deletions
Show diff stats
plugins/ldap/lib/ldap_authentication.rb
@@ -77,18 +77,20 @@ class LdapAuthentication | @@ -77,18 +77,20 @@ class LdapAuthentication | ||
77 | end | 77 | end |
78 | 78 | ||
79 | def get_user_attributes_from_ldap_entry(entry) | 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 | end | 87 | end |
86 | 88 | ||
87 | # Return the attributes needed for the LDAP search. It will only | 89 | # Return the attributes needed for the LDAP search. It will only |
88 | # include the user attributes if on-the-fly registration is enabled | 90 | # include the user attributes if on-the-fly registration is enabled |
89 | def search_attributes | 91 | def search_attributes |
90 | if onthefly_register? | 92 | if onthefly_register? |
91 | - ['dn', self.attr_fullname, self.attr_mail] | 93 | + nil |
92 | else | 94 | else |
93 | ['dn'] | 95 | ['dn'] |
94 | end | 96 | end |
@@ -111,6 +113,7 @@ class LdapAuthentication | @@ -111,6 +113,7 @@ class LdapAuthentication | ||
111 | end | 113 | end |
112 | login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) | 114 | login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) |
113 | object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) | 115 | object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) |
116 | + | ||
114 | attrs = {} | 117 | attrs = {} |
115 | 118 | ||
116 | search_filter = object_filter & login_filter | 119 | search_filter = object_filter & login_filter |
plugins/ldap/lib/ldap_plugin.rb
@@ -60,7 +60,7 @@ class LdapPlugin < Noosfero::Plugin | @@ -60,7 +60,7 @@ class LdapPlugin < Noosfero::Plugin | ||
60 | user.password = password | 60 | user.password = password |
61 | user.password_confirmation = password | 61 | user.password_confirmation = password |
62 | person_data = plugins.dispatch(:ldap_plugin_set_profile_data, attrs, login, context.params) | 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 | user.activated_at = Time.now.utc | 64 | user.activated_at = Time.now.utc |
65 | user.activation_code = nil | 65 | user.activation_code = nil |
66 | 66 |