diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-21 13:28:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-21 13:28:12 +0000 |
commit | b09a18972d0455c77f99dc9cc8d3c7cd5b81b373 (patch) | |
tree | 9908889009d7e62ddeabc911d025b4cf5863b1ca /app/models/auth_source_ldap.rb | |
parent | 8a356baf3e320607ec6f85dd33f7fa8887dc1ebd (diff) | |
download | redmine-b09a18972d0455c77f99dc9cc8d3c7cd5b81b373.tar.gz redmine-b09a18972d0455c77f99dc9cc8d3c7cd5b81b373.zip |
Strip LDAP attribute names before saving (#1890).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1894 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/auth_source_ldap.rb')
-rw-r--r-- | app/models/auth_source_ldap.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index 655ffd6d5..6203a7c85 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -25,6 +25,8 @@ class AuthSourceLdap < AuthSource validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true validates_numericality_of :port, :only_integer => true + before_validation :strip_ldap_attributes + def after_initialize self.port = 389 if self.port == 0 end @@ -71,7 +73,14 @@ class AuthSourceLdap < AuthSource "LDAP" end -private + private + + def strip_ldap_attributes + [:attr_login, :attr_firstname, :attr_lastname, :attr_mail].each do |attr| + write_attribute(attr, read_attribute(attr).strip) unless read_attribute(attr).nil? + end + end + def initialize_ldap_con(ldap_user, ldap_password) options = { :host => self.host, :port => self.port, |