ldap_filter.0.7.3.x3n.patch

Patch for the 0.7.3 version - Lionel Molinier, 2008-08-28 21:03

Download (4.17 KB)

View differences:

redmine-0.7.3-patched/app/models/auth_source_ldap.rb 2008-08-28 19:44:59.000000000 +0200
19 19
require 'iconv'
20 20

  
21 21
class AuthSourceLdap < AuthSource 
22
  validates_presence_of :host, :port, :attr_login
22
  validates_presence_of :host, :port, :filter, :attr_login
23 23
  validates_presence_of :attr_firstname, :attr_lastname, :attr_mail, :if => Proc.new { |a| a.onthefly_register? }
24 24
  
25 25
  def after_initialize
......
33 33
    ldap_con = initialize_ldap_con(self.account, self.account_password)
34 34
    login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) 
35 35
    object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) 
36
    
37
    # add the user defined filter
38
    custom_filter = Net::LDAP::Filter.construct( self.filter ) 
39

  
36 40
    dn = String.new
37 41
    ldap_con.search( :base => self.base_dn, 
38
                     :filter => object_filter & login_filter, 
42
                     :filter => object_filter & login_filter & custom_filter, 
39 43
                     # only ask for the DN if on-the-fly registration is disabled
40 44
                     :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry|
41 45
      dn = entry.dn
redmine-0.7.3-patched/app/models/auth_source.rb 2008-08-28 19:42:31.000000000 +0200
22 22
  validates_uniqueness_of :name
23 23
  validates_length_of :name, :host, :maximum => 60
24 24
  validates_length_of :account_password, :maximum => 60, :allow_nil => true
25
  validates_length_of :account, :base_dn, :maximum => 255
25
  validates_length_of :account, :base_dn, :filter, :maximum => 255
26 26
  validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30
27 27

  
28 28
  def authenticate(login, password)
redmine-0.7.3-patched/app/views/auth_sources/_form.rhtml 2008-08-28 19:46:20.000000000 +0200
22 22

  
23 23
<p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label>
24 24
<%= text_field 'auth_source', 'base_dn', :size => 60 %></p>
25

  
26
<p><label for="auth_source_filter"><%=l(:field_filter)%></label>
27
<%= text_field 'auth_source', 'filter', :size => 60 %></p>
28

  
25 29
</div>
26 30

  
27 31
<div class="box">
redmine-0.7.3-patched/db/migrate/001_setup.rb 2008-08-28 19:47:06.000000000 +0200
42 42
      t.column "account", :string, :limit => 60
43 43
      t.column "account_password", :string, :limit => 60
44 44
      t.column "base_dn", :string, :limit => 255
45
      t.column "filter", :string, :limit => 255
45 46
      t.column "attr_login", :string, :limit => 30
46 47
      t.column "attr_firstname", :string, :limit => 30
47 48
      t.column "attr_lastname", :string, :limit => 30
redmine-0.7.3-patched/lang/en.yml 2008-08-28 19:48:51.000000000 +0200
151 151
field_port: Port
152 152
field_account: Account
153 153
field_base_dn: Base DN
154
field_filter: Filter
154 155
field_attr_login: Login attribute
155 156
field_attr_firstname: Firstname attribute
156 157
field_attr_lastname: Lastname attribute
redmine-0.7.3-patched/lang/fr.yml 2008-08-28 19:48:01.000000000 +0200
151 151
field_port: Port
152 152
field_account: Compte
153 153
field_base_dn: Base DN
154
field_filter: Filtre
154 155
field_attr_login: Attribut Identifiant
155 156
field_attr_firstname: Attribut Prénom
156 157
field_attr_lastname: Attribut Nom