Patch #3358 » 07_ldap_sync.patch
| redmine-0.9.0.new/app/controllers/my_controller.rb 2009-07-14 15:18:01.514861128 +0200 | ||
|---|---|---|
|
@user.pref.attributes = params[:pref]
|
||
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||
|
if @user.save
|
||
|
if @user.auth_source and @user.auth_source.respond_to?('update')
|
||
|
@user.auth_source.update(@user.login, @user.firstname, @user.lastname, @user.mail)
|
||
|
end
|
||
|
@user.pref.save
|
||
|
@user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
|
||
|
set_language_if_valid @user.language
|
||
| redmine-0.9.0.new/app/models/auth_source_ldap.rb 2009-07-14 15:18:01.514861128 +0200 | ||
|---|---|---|
|
rescue LDAP::Error => text
|
||
|
raise "LDAP Auth Error: " + text
|
||
|
end
|
||
|
|
||
|
def update(login, firstname, lastname, mail)
|
||
|
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||
|
entry = [
|
||
|
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_firstname, [firstname]),
|
||
|
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_lastname, [lastname]),
|
||
|
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_mail, [mail])
|
||
|
]
|
||
|
if self.filter.empty?
|
||
|
filter = self.attr_login + "=" + encode(login)
|
||
|
else
|
||
|
filter = self.filter.gsub("$login", encode(login))
|
||
|
end
|
||
|
ldap_con.modify(filter + "," + self.base_dn, entry)
|
||
|
rescue LDAP::Error => text
|
||
|
raise "LDAP Auth Error: " + text
|
||
|
end
|
||
|
# test the connection to the LDAP
|
||
|
def test_connection
|
||
| redmine-0.9.0.new/app/models/user.rb 2009-07-14 16:18:47.845859827 +0200 | ||
|---|---|---|
|
return nil if !user.active?
|
||
|
if user.auth_source
|
||
|
# user has an external authentication method
|
||
|
return nil unless user.auth_source.authenticate(login, password)
|
||
|
attrs = user.auth_source.authenticate(login, password)
|
||
|
return nil unless attrs
|
||
|
# synchronise db with ldap
|
||
|
user.update_attributes(attrs[0])
|
||
|
else
|
||
|
# authentication with local password
|
||
|
return nil unless User.hash_password(password) == user.hashed_password
|
||