admin_externalpage_print_header();
if ($confirm and confirm_sesskey()) {
- $primaryadmin = get_admin();
+ // only force password change if user may actually change the password
+ $authsavailable = get_plugin_list('auth');
+ $changeable = array();
+ foreach($authsavailable as $authname=>$path) {
+ if (!$auth = get_auth_plugin($authname)) {
+ continue;
+ }
+ if (@$auth->can_change_password()) { // plugins may not be configured yet, not nice :-(
+ $changeable[$authname] = true;
+ }
+ }
$parts = array_chunk($SESSION->bulk_users, 300);
foreach ($parts as $users) {
list($in, $params) = $DB->get_in_or_equal($users);
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) {
foreach ($rs as $user) {
- set_user_preference('auth_forcepasswordchange', 1, $user->id);
+ if (!empty($changeable[$user->auth])) {
+ set_user_preference('auth_forcepasswordchange', 1, $user->id);
+ unset($SESSION->bulk_users[$user->id]);
+ } else {
+ echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true)));
+ }
}
$rs->close();
}