Patch #3358 » 07_ldap_update.patch
| redmine-0.9.0.new/app/controllers/my_controller.rb 2009-07-14 11:31:15.590861206 +0200 | ||
|---|---|---|
| 59 | 59 |
@user.pref.attributes = params[:pref] |
| 60 | 60 |
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
| 61 | 61 |
if @user.save |
| 62 |
if @user.auth_source and @user.auth_source.respond_to?('update')
|
|
| 63 |
@user.auth_source.update(@user.login, @user.firstname, @user.lastname, @user.mail) |
|
| 64 |
end |
|
| 62 | 65 |
@user.pref.save |
| 63 | 66 |
@user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
| 64 | 67 |
set_language_if_valid @user.language |
| redmine-0.9.0.new/app/models/auth_source_ldap.rb 2009-07-14 12:50:47.409859537 +0200 | ||
|---|---|---|
| 80 | 80 |
rescue LDAP::Error => text |
| 81 | 81 |
raise "LDAP Auth Error: " + text |
| 82 | 82 |
end |
| 83 |
|
|
| 84 |
def update(login, firstname, lastname, mail) |
|
| 85 |
ldap_con = initialize_ldap_con(self.account, self.account_password) |
|
| 86 |
entry = [ |
|
| 87 |
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_firstname, [firstname]), |
|
| 88 |
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_lastname, [lastname]), |
|
| 89 |
LDAP.mod(LDAP::LDAP_MOD_REPLACE, self.attr_mail, [mail]) |
|
| 90 |
] |
|
| 91 |
if self.filter.empty? |
|
| 92 |
filter = self.attr_login + "=" + encode(login) |
|
| 93 |
else |
|
| 94 |
filter = self.filter.gsub("$login", encode(login))
|
|
| 95 |
end |
|
| 96 |
ldap_con.modify(filter + "," + self.base_dn, entry) |
|
| 97 |
rescue LDAP::Error => text |
|
| 98 |
raise "LDAP Auth Error: " + text |
|
| 99 |
end |
|
| 83 | 100 | |
| 84 | 101 |
# test the connection to the LDAP |
| 85 | 102 |
def test_connection |