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