##// END OF EJS Templates
Fixed: 'LDAP account password is too long' error when leaving the field empty on creation....
Jean-Philippe Lang -
r964:7e9c45447879
parent child
Show More
@@ -1,50 +1,51
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class AuthSource < ActiveRecord::Base
18 class AuthSource < ActiveRecord::Base
19 has_many :users
19 has_many :users
20
20
21 validates_presence_of :name
21 validates_presence_of :name
22 validates_uniqueness_of :name
22 validates_uniqueness_of :name
23 validates_length_of :name, :host, :account_password, :maximum => 60
23 validates_length_of :name, :host, :maximum => 60
24 validates_length_of :account_password, :maximum => 60, :allow_nil => true
24 validates_length_of :account, :base_dn, :maximum => 255
25 validates_length_of :account, :base_dn, :maximum => 255
25 validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30
26 validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30
26
27
27 def authenticate(login, password)
28 def authenticate(login, password)
28 end
29 end
29
30
30 def test_connection
31 def test_connection
31 end
32 end
32
33
33 def auth_method_name
34 def auth_method_name
34 "Abstract"
35 "Abstract"
35 end
36 end
36
37
37 # Try to authenticate a user not yet registered against available sources
38 # Try to authenticate a user not yet registered against available sources
38 def self.authenticate(login, password)
39 def self.authenticate(login, password)
39 AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source|
40 AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source|
40 begin
41 begin
41 logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug?
42 logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug?
42 attrs = source.authenticate(login, password)
43 attrs = source.authenticate(login, password)
43 rescue
44 rescue
44 attrs = nil
45 attrs = nil
45 end
46 end
46 return attrs if attrs
47 return attrs if attrs
47 end
48 end
48 return nil
49 return nil
49 end
50 end
50 end
51 end
General Comments 0
You need to be logged in to leave comments. Login now