Feature #1060 » ldap_filter.0.7.3.x3n.patch
| redmine-0.7.3-patched/app/models/auth_source_ldap.rb 2008-08-28 19:44:59.000000000 +0200 | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| redmine-0.7.3-patched/app/models/auth_source.rb 2008-08-28 19:42:31.000000000 +0200 | ||
|---|---|---|
|
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)
|
||
| redmine-0.7.3-patched/app/views/auth_sources/_form.rhtml 2008-08-28 19:46:20.000000000 +0200 | ||
|---|---|---|
|
<p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label>
|
||
|
<%= text_field 'auth_source', 'base_dn', :size => 60 %></p>
|
||
|
<p><label for="auth_source_filter"><%=l(:field_filter)%></label>
|
||
|
<%= text_field 'auth_source', 'filter', :size => 60 %></p>
|
||
|
</div>
|
||
|
<div class="box">
|
||
| redmine-0.7.3-patched/db/migrate/001_setup.rb 2008-08-28 19:47:06.000000000 +0200 | ||
|---|---|---|
|
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
|
||
| redmine-0.7.3-patched/lang/en.yml 2008-08-28 19:48:51.000000000 +0200 | ||
|---|---|---|
|
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
|
||
| redmine-0.7.3-patched/lang/fr.yml 2008-08-28 19:48:01.000000000 +0200 | ||
|---|---|---|
|
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
|
||