diff -Nur redmine-0.6.3/app/models/auth_source.rb redmine-0.6.3-patched/app/models/auth_source.rb --- redmine-0.6.3/app/models/auth_source.rb 2007-12-18 19:17:39.000000000 +0100 +++ redmine-0.6.3-patched/app/models/auth_source.rb 2008-04-14 11:44:53.000000000 +0200 @@ -22,7 +22,7 @@ validates_uniqueness_of :name validates_length_of :name, :host, :maximum => 60 validates_length_of :account_password, :maximum => 60, :allow_nil => true - validates_length_of :account, :base_dn, :maximum => 255 + validates_length_of :account, :base_dn, :filter, :maximum => 255 validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30 def authenticate(login, password) diff -Nur redmine-0.6.3/app/models/auth_source_ldap.rb redmine-0.6.3-patched/app/models/auth_source_ldap.rb --- redmine-0.6.3/app/models/auth_source_ldap.rb 2007-12-18 19:17:39.000000000 +0100 +++ redmine-0.6.3-patched/app/models/auth_source_ldap.rb 2008-04-14 11:44:53.000000000 +0200 @@ -19,11 +19,12 @@ require 'iconv' class AuthSourceLdap < AuthSource - validates_presence_of :host, :port, :attr_login + validates_presence_of :host, :port, :filter, :attr_login validates_presence_of :attr_firstname, :attr_lastname, :attr_mail, :if => Proc.new { |a| a.onthefly_register? } def after_initialize self.port = 389 if self.port == 0 + self.filter = "()" if self.filter == "" end def authenticate(login, password) @@ -32,9 +33,13 @@ ldap_con = initialize_ldap_con(self.account, self.account_password) login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) + + # Add the user defined filter + custom_filter = Net::LDAP::Filter.construct( self.filter ) + dn = String.new ldap_con.search( :base => self.base_dn, - :filter => object_filter & login_filter, + :filter => object_filter & login_filter & custom_filter, # only ask for the DN if on-the-fly registration is disabled :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry| dn = entry.dn diff -Nur redmine-0.6.3/app/views/auth_sources/_form.rhtml redmine-0.6.3-patched/app/views/auth_sources/_form.rhtml --- redmine-0.6.3/app/views/auth_sources/_form.rhtml 2007-12-18 19:17:41.000000000 +0100 +++ redmine-0.6.3-patched/app/views/auth_sources/_form.rhtml 2008-04-14 11:44:53.000000000 +0200 @@ -22,6 +22,9 @@

<%= text_field 'auth_source', 'base_dn', :size => 60 %>

+ +

+<%= text_field 'auth_source', 'filter', :size => 60 %>

diff -Nur redmine-0.6.3/db/migrate/001_setup.rb redmine-0.6.3-patched/db/migrate/001_setup.rb --- redmine-0.6.3/db/migrate/001_setup.rb 2007-12-18 19:17:47.000000000 +0100 +++ redmine-0.6.3-patched/db/migrate/001_setup.rb 2008-04-14 11:44:53.000000000 +0200 @@ -42,6 +42,7 @@ t.column "account", :string, :limit => 60 t.column "account_password", :string, :limit => 60 t.column "base_dn", :string, :limit => 255 + t.column "filter", :string, :limit => 255 t.column "attr_login", :string, :limit => 30 t.column "attr_firstname", :string, :limit => 30 t.column "attr_lastname", :string, :limit => 30 diff -Nur redmine-0.6.3/lang/en.yml redmine-0.6.3-patched/lang/en.yml --- redmine-0.6.3/lang/en.yml 2007-12-18 19:17:44.000000000 +0100 +++ redmine-0.6.3-patched/lang/en.yml 2008-04-14 11:45:24.000000000 +0200 @@ -145,6 +145,7 @@ field_port: Port field_account: Account field_base_dn: Base DN +field_filter: Filter field_attr_login: Login attribute field_attr_firstname: Firstname attribute field_attr_lastname: Lastname attribute diff -Nur redmine-0.6.3/lang/fr.yml redmine-0.6.3-patched/lang/fr.yml --- redmine-0.6.3/lang/fr.yml 2007-12-18 19:17:44.000000000 +0100 +++ redmine-0.6.3-patched/lang/fr.yml 2008-04-14 11:45:24.000000000 +0200 @@ -145,6 +145,7 @@ field_port: Port field_account: Compte field_base_dn: Base DN +field_filter: Filtre field_attr_login: Attribut Identifiant field_attr_firstname: Attribut Prénom field_attr_lastname: Attribut Nom