diff -Nur redmine-0.7.3/app/models/auth_source_ldap.rb redmine-0.7.3-patched/app/models/auth_source_ldap.rb --- redmine-0.7.3/app/models/auth_source_ldap.rb 2008-07-06 13:17:46.000000000 +0200 +++ redmine-0.7.3-patched/app/models/auth_source_ldap.rb 2008-08-28 19:44:59.000000000 +0200 @@ -19,7 +19,7 @@ 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 @@ -33,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.7.3/app/models/auth_source.rb redmine-0.7.3-patched/app/models/auth_source.rb --- redmine-0.7.3/app/models/auth_source.rb 2008-07-06 13:17:46.000000000 +0200 +++ redmine-0.7.3-patched/app/models/auth_source.rb 2008-08-28 19:42:31.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.7.3/app/views/auth_sources/_form.rhtml redmine-0.7.3-patched/app/views/auth_sources/_form.rhtml --- redmine-0.7.3/app/views/auth_sources/_form.rhtml 2008-07-06 13:17:46.000000000 +0200 +++ redmine-0.7.3-patched/app/views/auth_sources/_form.rhtml 2008-08-28 19:46:20.000000000 +0200 @@ -22,6 +22,10 @@

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

+ +

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

+
diff -Nur redmine-0.7.3/db/migrate/001_setup.rb redmine-0.7.3-patched/db/migrate/001_setup.rb --- redmine-0.7.3/db/migrate/001_setup.rb 2008-07-06 13:17:50.000000000 +0200 +++ redmine-0.7.3-patched/db/migrate/001_setup.rb 2008-08-28 19:47:06.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.7.3/lang/en.yml redmine-0.7.3-patched/lang/en.yml --- redmine-0.7.3/lang/en.yml 2008-07-06 13:17:48.000000000 +0200 +++ redmine-0.7.3-patched/lang/en.yml 2008-08-28 19:48:51.000000000 +0200 @@ -151,6 +151,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.7.3/lang/fr.yml redmine-0.7.3-patched/lang/fr.yml --- redmine-0.7.3/lang/fr.yml 2008-07-06 13:17:48.000000000 +0200 +++ redmine-0.7.3-patched/lang/fr.yml 2008-08-28 19:48:01.000000000 +0200 @@ -151,6 +151,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