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 %>
+