please don't use the MOODLE_15_LDAP branch any more.
echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
require_once("$CFG->dirroot/auth/$auth/config.html");
-
+ echo "<tr><td colspan=\"2\"><h2>";
+ print_string("auth_common_settings", "auth");
+ echo "</h2><td/></tr>";
+
if ($auth != "email" and $auth != "none" and $auth != "manual") {
echo "<tr valign=\"top\">";
echo "<td align=\"right\" nowrap=\"nowrap\"><p>";
-<?php
- if (!isset($config->ldap_host_url)) {
- $config->ldap_host_url = "";
- }
- if (!isset($config->ldap_contexts)) {
- $config->ldap_contexts = "";
- }
- if (!isset($config->ldap_user_attribute)) {
- $config->ldap_user_attribute = "";
- }
- if (!isset($config->ldap_search_sub)) {
- $config->ldap_search_sub = "";
- }
- if (!isset($config->ldap_bind_dn)) {
- $config->ldap_bind_dn = "";
- }
- if (!isset($config->ldap_bind_pw)) {
- $config->ldap_bind_pw = "";
- }
- if (empty($config->ldap_version)) {
- $config->ldap_version = "2";
- }
- if (empty($config->ldap_memberattribute)) {
- $config->ldap_memberattribute = "";
- }
- if (empty($config->ldap_creators)) {
- $config->ldap_creators = "";
- }
- if (empty($config->ldap_create_context)) {
- $config->ldap_create_context = "";
- }
- if (empty($config->ldap_objectclass)) {
- $config->ldap_objectclass = "";
- }
- if (empty($config->auth_user_guid)) {
- $config->auth_user_guid = "";
- }
+<?PHP
+ // Initialize vars
+ optional_variable($config->ldap_host_url, "");
+ optional_variable($config->ldap_contexts, "");
+ optional_variable($config->ldap_user_attribute, "");
+ optional_variable($config->ldap_search_sub, "");
+ optional_variable($config->ldap_bind_dn, "");
+ optional_variable($config->ldap_bind_pw, "");
+ optional_variable($config->ldap_version, "2");
+ optional_variable($config->ldap_objectclass, "");
+ optional_variable($config->ldap_memberattribute, "");
+ optional_variable($config->ldap_creators, "");
+ optional_variable($config->ldap_create_context, "");
+ optional_variable($config->auth_ldap_expirecheck, "");
+ optional_variable($config->auth_ldap_expireattr, "");
+ optional_variable($config->auth_ldap_expiredaysbefore, "");
+ optional_variable($config->auth_ldap_gracecheck, "");
+ optional_variable($config->auth_ldap_graceattr, "");
+ optional_variable($config->auth_user_create, "");
+ optional_variable($config->auth_user_create, "");
+ optional_variable($config->auth_ldap_forcepasswordchange, "");
+
+ optional_variable($config->auth_user_firstname_updatelocal, "");
+ optional_variable($config->auth_user_firstname_editlock, "");
+ optional_variable($config->auth_user_firstname_updateremote, "");
+ optional_variable($config->auth_user_lastname_updatelocal, "");
+ optional_variable($config->auth_user_lastname_editlock, "");
+ optional_variable($config->auth_user_lastname_updateremote, "");
+ optional_variable($config->auth_user_email_updatelocal, "");
+ optional_variable($config->auth_user_email_editlock, "");
+ optional_variable($config->auth_user_email_updateremote, "");
+ optional_variable($config->auth_user_phone1_updatelocal, "");
+ optional_variable($config->auth_user_phone1_editlock, "");
+ optional_variable($config->auth_user_phone1_updateremote, "");
+ optional_variable($config->auth_user_phone2_updatelocal, "");
+ optional_variable($config->auth_user_phone2_editlock, "");
+ optional_variable($config->auth_user_phone2_updateremote, "");
+ optional_variable($config->auth_user_department_updatelocal, "");
+ optional_variable($config->auth_user_department_editlock, "");
+ optional_variable($config->auth_user_department_updateremote, "");
+ optional_variable($config->auth_user_address_updatelocal, "");
+ optional_variable($config->auth_user_address_editlock, "");
+ optional_variable($config->auth_user_address_updateremote, "");
+ optional_variable($config->auth_user_city_updatelocal, "");
+ optional_variable($config->auth_user_city_editlock, "");
+ optional_variable($config->auth_user_city_updateremote, "");
+ optional_variable($config->auth_user_country_updatelocal, "");
+ optional_variable($config->auth_user_country_editlock, "");
+ optional_variable($config->auth_user_country_updateremote, "");
+ optional_variable($config->auth_user_description_updatelocal, "");
+ optional_variable($config->auth_user_description_editlock, "");
+ optional_variable($config->auth_user_description_updateremote, "");
+ optional_variable($config->auth_user_lang_updatelocal, "");
+ optional_variable($config->auth_user_lang_editlock, "");
+ optional_variable($config->auth_user_lang_updateremote, "");
+ optional_variable($config->auth_user_idnumber_updatelocal, "");
+ optional_variable($config->auth_user_idnumber_editlock, "");
+ optional_variable($config->auth_user_idnumber_updateremote, "");
+ optional_variable($config->auth_ldap_stdchangepassword, false);
+
+if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
+ print '<p align="center"><font color="red"><strong>Warning:
+ The PHP LDAP module does not seem to be present.
+ Please ensure it is installed and enabled.</strong></font></p>';
+}
+
?>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_host_url:</td>
- <td>
- <input name="ldap_host_url" type="text" size="30" value="<?php echo $config->ldap_host_url?>" />
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("auth_ldap_server_settings", "auth") ?> </h2>
+ </td>
+</tr>
+
+<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_host_url:</TD>
+ <TD>
+ <INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_host_url?>">
<?php if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
- </td>
- <td>
+ </TD>
+ <TD>
<?php print_string("auth_ldap_host_url","auth") ?>
- </td>
-</tr>
+ </TD>
+</TR>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_version:</td>
- <td>
+<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_version:</TD>
+ <TD>
<?php
$versions[2] = "2";
$versions[3] = "3";
choose_from_menu($versions, "ldap_version", $config->ldap_version, "");
if (isset($err["ldap_version"])) formerr($err["ldap_version"]);
?>
- </td>
- <td>
+ </TD>
+ <TD>
<?php print_string("auth_ldap_version","auth") ?>
- </td>
+ </TD>
+</TR>
+
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("auth_ldap_bind_settings", "auth") ?> </h2>
+ </td>
</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_contexts:</td>
- <td>
- <input name="ldap_contexts" type="text" size="30" value="<?php echo $config->ldap_contexts?>" />
- <?php if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
- </td>
- <td>
- <?php print_string("auth_ldap_contexts","auth") ?>
- </td>
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
+ <TD>
+ <INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_dn?>">
+ <?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
+ </TD><TD>
+ <?php print_string("auth_ldap_bind_dn","auth") ?>
+ </TD>
+</TR>
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
+ <TD>
+ <INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_pw?>">
+ <?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
+ </TD><TD>
+ <?php print_string("auth_ldap_bind_pw","auth") ?>
+ </TD>
+</TR>
+
+
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("auth_ldap_user_settings", "auth") ?> </h2>
+ </td>
</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_user_attribute:</td>
- <td>
- <input name="ldap_user_attribute" type="text" size="30" value="<?php echo $config->ldap_user_attribute?>" />
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
+ <TD>
+ <INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_user_attribute?>">
<?php if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
- </td>
- <td>
+ </TD>
+ <TD>
<?php print_string("auth_ldap_user_attribute","auth") ?>
- </td>
-</tr>
+ </TD>
+</TR>
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_memberattribute:</TD>
+ <TD>
+ <INPUT name=ldap_memberattribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_memberattribute?>">
+ <?php if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
+ </TD><TD>
+ <?php print_string("auth_ldap_memberattribute","auth") ?>
+ </TD>
+</TR>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_objectclass:</td>
- <td>
- <input name="ldap_objectclass" type="text" size="30" value="<?php echo $config->ldap_objectclass?>" />
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_objectclass:</TD>
+ <TD>
+ <INPUT name=ldap_objectclass TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_objectclass?>">
<?php if (isset($err["ldap_objectclass"])) formerr($err["ldap_objectclass"]); ?>
- </td>
- <td>
+ </TD>
+ <TD>
<?php print_string("auth_ldap_objectclass","auth") ?>
- </td>
-</tr>
+ </TD>
+</TR>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_search_sub:</td>
- <td>
- <input name="ldap_search_sub" type="text" size="1" value="<?php echo $config->ldap_search_sub?>" />
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_contexts:</TD>
+ <TD>
+ <INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_contexts?>">
+ <?php if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
+ </TD>
+ <TD>
+ <?php print_string("auth_ldap_contexts","auth") ?>
+ </TD>
+</TR>
+
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
+ <TD>
+ <INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?php echo $config->ldap_search_sub?>">
<?php if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
- </td>
- <td>
+ </TD>
+ <TD>
<?php print_string("auth_ldap_search_sub","auth") ?>
- </td>
+ </TD>
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("auth_user_create", "auth") ?> </h2>
+ </td>
</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_bind_dn:</td>
- <td>
- <input name="ldap_bind_dn" type="text" size="30" value="<?php echo $config->ldap_bind_dn?>" />
- <?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
- </td><td>
- <?php print_string("auth_ldap_bind_dn","auth") ?>
- </td>
-</tr>
+</TR>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_create_context:</TD>
+ <TD>
+ <INPUT name=ldap_create_context TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_create_context?>">
+ <?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
+ </TD><TD>
+ <?php print_string("auth_ldap_create_context","auth") ?>
+ </TD>
+</TR>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_bind_pw:</td>
- <td>
- <input name="ldap_bind_pw" type="text" size="30" value="<?php echo $config->ldap_bind_pw?>" />
- <?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
- </td><td>
- <?php print_string("auth_ldap_bind_pw","auth") ?>
- </td>
-</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_memberattribute:</td>
- <td>
- <input name="ldap_memberattribute" type="text" size="30" value="<?php echo $config->ldap_memberattribute?>" />
- <?php if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
- </td><td>
- <?php print_string("auth_ldap_memberattribute","auth") ?>
- </td>
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("coursecreators") ?> </h2>
+ </td>
</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_creators:</td>
- <td>
- <input name="ldap_creators" type="text" size="30" value="<?php echo $config->ldap_creators?>" />
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>ldap_creators:</TD>
+ <TD>
+ <INPUT name=ldap_creators TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_creators?>">
<?php if (isset($err["ldap_creators"])) formerr($err["ldap_creators"]); ?>
- </td><td>
+ </TD><TD>
<?php print_string("auth_ldap_creators","auth") ?>
- </td>
+ </TD>
+</TR>
+<tr>
+ <td colspan="2">
+ <h2><?php print_string("auth_data_mapping", "auth") ?> </h2>
+ </td>
</tr>
-<tr valign="top" bgcolor="<?php echo $THEME->cellheading2 ?>">
- <td align="right"><p>ldap_create_context:</td>
- <td>
- <input name="ldap_create_context" type="text" size="30" value="<?php echo $config->ldap_create_context?>" />
- <?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
- </td><td>
- <?php print_string("auth_ldap_create_context","auth") ?>
- </td>
-</tr>
-<tr>
- <td align="right"><p><?php print_string("firstname") ?>:</td>
- <td>
- <input name="auth_user_firstname" type="text" size="30" value="<?php echo $config->auth_user_firstname?>" />
- </td>
- <td rowspan="12" valign="middle">
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_firstname_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_firstname_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_firstname_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_firstname_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_firstname_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_firstname_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_firstname_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_firstname_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_firstname_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+ <TD rowspan=12 VALIGN=TOP>
<?php print_string("auth_ldapextrafields","auth") ?>
- </td>
-</tr>
+ <?php print_string("auth_updatelocal_expl","auth") ?>
+ <?php print_string("auth_editlock_expl","auth") ?>
+ <?php print_string("auth_updateremote_expl","auth") ?>
+ <hr>
+ <?php print_string("auth_updateremote_ldap","auth") ?>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("lastname") ?>:</td>
- <td>
- <input name="auth_user_lastname" type="text" size="30" value="<?php echo $config->auth_user_lastname?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_lastname_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lastname_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lastname_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock","auth") ?>
+ <SELECT NAME="auth_user_lastname_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lastname_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lastname_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_lastname_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lastname_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lastname_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("email") ?>:</td>
- <td>
- <input name="auth_user_email" type="text" size="30" value="<?php echo $config->auth_user_email?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_email_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_email_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_email_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_email_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_email_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_email_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_email_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_email_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_email_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("phone") ?> 1:</td>
- <td>
- <input name="auth_user_phone1" type="text" size="30" value="<?php echo $config->auth_user_phone1?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
+ <TD>
+ <INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_phone1_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone1_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone1_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_phone1_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone1_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone1_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_phone1_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone1_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone1_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("phone") ?> 2:</td>
- <td>
- <input name="auth_user_phone2" type="text" size="30" value="<?php echo $config->auth_user_phone2?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
+ <TD>
+ <INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_phone2_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone2_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone2_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_phone2_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone2_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone2_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_phone2_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_phone2_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_phone2_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("department") ?>:</td>
- <td>
- <input name="auth_user_department" type="text" size="30" value="<?php echo $config->auth_user_department?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_department_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_department_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_department_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_department_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_department_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_department_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_department_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_department_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_department_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("address") ?>:</td>
- <td>
- <input name="auth_user_address" type="text" size="30" value="<?php echo $config->auth_user_address?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_address_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_address_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_address_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_address_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_address_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_address_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_address_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_address_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_address_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("city") ?>:</td>
- <td>
- <input name="auth_user_city" type="text" size="30" value="<?php echo $config->auth_user_city?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_city_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_city_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_city_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_city_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_city_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_city_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_city_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_city_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_city_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("country") ?>:</td>
- <td>
- <input name="auth_user_country" type="text" size="30" value="<?php echo $config->auth_user_country?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_country_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_country_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_country_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_country_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_country_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_country_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_country_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_country_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_country_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("description") ?>:</td>
- <td>
- <input name="auth_user_description" type="text" size="30" value="<?php echo $config->auth_user_description?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_description_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_description_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_description_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_description_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_description_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_description_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_description_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_description_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_description_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("idnumber") ?>:</td>
- <td>
- <input name="auth_user_idnumber" type="text" size="30" value="<?php echo $config->auth_user_idnumber?>" />
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><p><?php print_string("language") ?>:</td>
- <td>
- <input name="auth_user_lang" type="text" size="30" value="<?php echo $config->auth_user_lang?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_idnumber_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_idnumber_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_idnumber_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_idnumber_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_idnumber_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_idnumber_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_idnumber_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_idnumber_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_idnumber_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("guid") ?>:</td>
- <td>
- <input name="auth_user_guid" type="text" size="30" value="<?php echo $config->auth_user_guid?>" />
- </td>
-</tr>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
+ <DIV ALIGN="right">
+ <?php print_string("auth_updatelocal", "auth") ?>
+ <SELECT NAME="auth_user_lang_updatelocal">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lang_updatelocal ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lang_updatelocal ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_editlock", "auth") ?>
+ <SELECT NAME="auth_user_lang_editlock">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lang_editlock ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lang_editlock ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ <?php print_string("auth_updateremote", "auth") ?>
+ <SELECT NAME="auth_user_lang_updateremote">
+ <OPTION VALUE="0" <?php echo ($config->auth_user_lang_updateremote ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_user_lang_updateremote ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </DIV>
+ </TD>
+</TR>
-<tr valign="top">
- <td align="right"><p><?php print_string("instructions", "auth") ?>:</td>
- <td>
- <textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
- </td>
- <td>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
+ <TD>
+ <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
+ </TD>
+ <TD>
<?php print_string("authinstructions","auth") ?>
<?php helpbutton("text", get_string("helptext")) ?>
- </td>
-</tr>
+ </TD>
+</TR>
+
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT VALIGN=TOP><P><?php print_string('forcechangepassword', 'auth') ?>:</P></TD>
+ <TD>
+
+ <SELECT NAME="auth_ldap_forcechangepassword">
+ <OPTION VALUE="0" <?php echo ($config->auth_ldap_forcechangepassword ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_ldap_forcechangepassword ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </TD>
+ <TD ALIGN=LEFT VALIGN=TOP>
+ <P><?php print_string('forcechangepassword_help', 'auth') ?></P>
+ </TD>
+</TR>
+<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT VALIGN=TOP><P><?php print_string('stdchangepassword', 'auth') ?>:</P></TD>
+ <TD>
+ <SELECT NAME="auth_ldap_stdchangepassword">
+ <OPTION VALUE="0" <?php echo ($config->auth_ldap_stdchangepassword ? '' : 'SELECTED="yes"') ?> >
+ <?php print_string("no") ?></OPTION>
+ <OPTION VALUE="1" <?php echo ($config->auth_ldap_stdchangepassword ? 'SELECTED="yes"' : '') ?> >
+ <?php print_string("yes") ?></OPTION>
+ </SELECT><BR>
+ </TD>
+ <TD ALIGN=LEFT VALIGN=TOP>
+ <P><?php print_string('stdchangepassword_expl', 'auth') ?></P>
+ <P><?php print_string('stdchangepassword_explldap', 'auth') ?></P>
+ </TD>
+</TR>
-<?php // $Id$
+<?PHP // $Id$
//CHANGELOG:
+//19.09.2004 Lot of changes are coming from Martin Langhoff
+// Current code is working but can change a lot. Be warned...
//15.08.2004 Added support for user syncronization
//24.02.2003 Added support for coursecreators
//20.02.2003 Added support for user creation
so all default values are for it.
LDAP USER SYNCRONIZATION
+!!!! Following comlete outdated as guid-field is not used anymorein moodeles user-table
+!!!! I'll update this documentation as soon ldap-code get more stabile.
BACKUP
This is first version of usersync so backup your database, if you like to test this feature!
$result[$key]=$user_entry[0][strtolower($value)][0];
}
}
- $result['guid']='ldap';
}
@ldap_close($ldap_connection);
auth_ldap_bind($ldap_connection);
- if (! isset($CFG->ldap_objectclass)) {
+ if (empty($CFG->ldap_objectclass)) {
$CFG->ldap_objectclass="objectClass=*";
}
return $fresult;
}
-function auth_sync_users () {
+function auth_sync_users ($unsafe_optimizations = false, $bulk_insert_records = 1) {
//Syncronizes userdb with ldap
//This will add, rename
+/// OPTIONAL PARAMETERS
+/// $unsafe_optimizations = true // will skip over moodle standard DB interfaces and use very optimized
+/// and non-portable SQL -- useful only for mysql or postgres7
+/// $bulk_insert_records = 1 // will insert $bulkinsert_records per insert statement
+/// valid only with $unsafe. increase to a couple thousand for
+/// blinding fast inserts -- but test it: you may hit mysqld's
+/// max_allowed_packet limit.
+
global $CFG ;
- $users = auth_get_users();
- $usedguids = Array();
+ $ldapusers = auth_get_users();
+ $usedidnumbers = Array();
+
+ // these are only populated if we managed to find added/removed users
+ $add_users = false;
+ $remove_users = false;
+
+ if($unsafe_optimizations){
+ // create a temp table
+ if(strtolower($CFG->dbtype) === 'mysql'){
+ // help old mysql versions cope with large temp tables
+ execute_sql('SET SQL_BIG_TABLES=1');
+ execute_sql('CREATE TEMPORARY TABLE ' . $CFG->prefix .'extuser (idnumber VARCHAR(12), PRIMARY KEY (idnumber)) TYPE=MyISAM');
+ } elseif (strtolower($CFG->dbtype) === 'postgres7'){
+ execute_sql('CREATE TEMPORARY TABLE '.$CFG->prefix.'extuser (idnumber VARCHAR(12), PRIMARY KEY (idnumber))');
+ }
+
+ $userids = array_keys($ldapusers);
+ // bulk insert -- superfast with $bulk_insert_records
+ while(count($userids)){
+ $sql = 'INSERT INTO '.$CFG->prefix.'extuser (idnumber) VALUES ';
+ $values = array_splice($userids, -($bulk_insert_records) );
+ // make those values safe
+ array_map('addslashes', $values);
+ // join and quote the whole lot
+ $sql = $sql . '(\'' . join('\'),(\'', $values) . '\')';
+ execute_sql($sql);
+ }
+
+ /// REMOVE execute_sql('delete from mdl_user where idnumber like \'%s\'');
+
+ // find users in DB that aren't in ldap -- to be removed!
+ $sql = 'SELECT u.*
+ FROM ' . $CFG->prefix .'user u LEFT JOIN ' . $CFG->prefix .'extuser e
+ ON u.idnumber = e.idnumber
+ WHERE u.auth=\'ldap\' AND u.deleted=\'0\' AND e.idnumber IS NULL';
+ $remove_users = get_records_sql($sql);
+ print "User entries to remove: ". count($remove_users) . "\n";
+
+ // find users missing in DB that are in LDAP
+ // note that get_records_sql wants at least 2 fields returned,
+ // and gives me a nifty object I don't want.
+ $sql = 'SELECT e.idnumber,1
+ FROM ' . $CFG->prefix .'extuser e LEFT JOIN ' . $CFG->prefix .'user u
+ ON e.idnumber = u.idnumber
+ WHERE u.id IS NULL';
+ $add_users = array_keys(get_records_sql($sql)) || array(); // get rid of the fat
+ print "User entries to add: ". count($add_users). "\n";
+ }
+
+ foreach ($ldapusers as $user) {
- foreach ($users as $user) {
- $usedguids[] = $user->guid; //we will need all used guids later
+ $usedidnumbers[] = $user->idnumber; //we will need all used idnumbers later
//update modified time
$user->modified = time();
//All users are confirmed
$user->confirmed = 1;
// if user does not exist create it
- if (!record_exists('user','auth', 'ldap', 'guid', $user->guid)) {
+ if ( ($unsafe_optimizations && is_array($add_users) && in_array($user->idnumber, $add_users) )
+ || (!$unsafe_optimizations &&!record_exists('user','auth', 'ldap', 'idnumber', $user->idnumber)) ) {
if (insert_record ('user',$user)) {
- echo "inserted user $user->username with guid $user->guid \n";
+ echo "inserted user $user->username with idnumber $user->idnumber \n";
} else {
- echo "error inserting user $user->username with guid $user->guid \n";
+ echo "error inserting user $user->username with idnumber $user->idnumber \n";
}
+ update_user_record($user->username);
continue ;
} else {
//update username
- set_field('user', 'username', $user->username , 'auth', 'ldap', 'guid', $user->guid);
+ set_field('user', 'username', $user->username , 'auth', 'ldap', 'idnumber', $user->idnumber);
//no id-information in ldap so get now
- $userid = get_field('user', 'id', 'auth', 'ldap', 'guid', $user->guid);
-
+ update_user_record($user->username);
+ $userid = get_field('user', 'id', 'auth', 'ldap', 'idnumber', $user->idnumber);
+
if (auth_iscreator($user->username)) {
if (! record_exists("user_coursecreators", "userid", $userid)) {
$cdata['userid']=$userid;
}
}
- //find nonexisting users from moodles userdb
- $sql = "SELECT * FROM ".$CFG->prefix."user WHERE deleted = '0' AND auth = 'ldap' AND guid NOT IN ('".implode('\' , \'',$usedguids)."');" ;
- $result = get_records_sql($sql);
+ if($unsafe_optimizations){
+ $result=(is_array($remove_users) ? $remove_users : array());
+ } else{
+ //find nonexisting users from moodles userdb
+ $sql = "SELECT * FROM ".$CFG->prefix."user WHERE deleted = '0' AND auth = 'ldap' AND idnumber NOT IN ('".implode('\' , \'',$usedidnumbers)."');" ;
+ $result = get_records_sql($sql);
+ }
if (!empty($result)){
foreach ($result as $user) {
}
+function auth_user_update($olduser, $newuser) {
+/// called when the user record is updated. push fields to
+/// the LDAP database if configured to do so...
+
+ global $USER , $CFG;
+
+ $ldap_connection = auth_ldap_connect();
+ $ldapbind = auth_ldap_bind($ldap_connection);
+
+ $result = array();
+ $search_attribs = array();
+
+ $attrmap = auth_ldap_attributes();
+ foreach ($attrmap as $key=>$value) {
+ if (!in_array($value, $search_attribs)) {
+ array_push($search_attribs, $value);
+ }
+ }
+
+ $user_dn = auth_ldap_find_userdn($ldap_connection, $olduser->username);
+
+ if (empty($CFG->ldap_objectclass)) {
+ $CFG->ldap_objectclass="objectClass=*";
+ }
+
+ $user_info_result = ldap_read($ldap_connection,$user_dn,$CFG->ldap_objectclass, $search_attribs);
+
+ if ($user_info_result){
+
+ $user_entry = ldap_get_entries($ldap_connection, $user_info_result);
+ //error_log(var_export($user_entry) . 'fpp' );
+
+ foreach ($attrmap as $key=>$ldapkey){
+ if (isset($CFG->{'auth_user_'. $key.'_updateremote'}) && $CFG->{'auth_user_'. $key.'_updateremote'}){
+ // skip update if the values already match
+ if( !($newuser->$key === $user_entry[0][strtolower($ldapkey)][0]) ){
+ ldap_modify($ldap_connection, $user_dn, array($ldapkey => utf8_encode($newuser->$key)));
+ } else {
+ error_log("Skip updating field $key for entry $user_dn: it seems to be already same on LDAP. " .
+ " old moodle value: '" . $olduser->$key .
+ "' new value '" . $newuser->$key .
+ "' current value in ldap entry " . $user_entry[0][strtolower($ldapkey)][0]);
+ }
+ }
+ }
+
+
+ } else {
+ error_log("ERROR:No user found in LDAP");
+ @ldap_close($ldap_connection);
+ return false;
+ }
+
+ @ldap_close($ldap_connection);
+
+ return true;
+
+}
+
+function auth_user_update_password($username, $newpassword) {
+/// called when the user password is updated -- it assumes it is called by an admin
+/// or that you've otherwise checked the user's credentials
+/// IMPORTANT: $newpassword must be cleartext, not crypted/md5'ed
+
+ global $CFG;
+ $result = false;
+
+ $ldap_connection = auth_ldap_connect();
+ $ldapbind = auth_ldap_bind($ldap_connection);
+
+
+
+ $user_dn = auth_ldap_find_userdn($ldap_connection, $username);
+
+ if(!$user_dn){
+ error_log('LDAP Error in auth_user_update_password(). No DN for: ' . $username);
+ return false;
+ }
+ // send ldap the password in cleartext, it will md5 it itself
+ $result = ldap_modify($ldap_connection, $user_dn, array('userPassword' => $newpassword));
+
+ if(!$result){
+ error_log('LDAP Error in auth_user_update_password(). Error code: '
+ . ldap_errno($ldap_connection) . '; Error string : '
+ . ldap_err2str(ldap_errno($ldap_connection)));
+ }
+
+ @ldap_close($ldap_connection);
+
+ return $result;
+}
+
//PRIVATE FUNCTIONS starts
//private functions are named as auth_ldap*
$config = (array)$CFG;
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
"department", "address", "city", "country", "description",
- "idnumber", "lang", "guid");
+ "idnumber", "lang" );
$moodleattributes = array();
foreach ($fields as $field) {
- if ($config["auth_user_$field"]) {
+ if (!empty($config["auth_user_$field"])) {
$moodleattributes[$field] = $config["auth_user_$field"];
}
}
auth_ldap_bind($ldap_connection);
- if (! isset($CFG->ldap_objectclass)) {
+ if (empty($CFG->ldap_objectclass)) {
$CFG->ldap_objectclass="objectClass=*";
}
$string['auth_dbtitle'] = 'Use an external database';
$string['auth_dbtype'] = 'The database type (See the <a href=\"../lib/adodb/readme.htm#drivers\">ADOdb documentation</a> for details)';
$string['auth_dbuser'] = 'Username with read access to the database';
+$string['auth_editlock'] = 'Lock value';
+$string['auth_editlock_expl'] = '<p><b>Lock value:</b> If enabled, will prevent Moodle users and admins from editing the field directly. Use this option if you are maintaining this data in the external auth system. </p>';
$string['auth_emaildescription'] = 'Email confirmation is the default authentication method. When the user signs up, choosing their own new username and password, a confirmation email is sent to the user\'s email address. This email contains a secure link to a page where the user can confirm their account. Future logins just check the username and password against the stored values in the Moodle database.';
$string['auth_emailtitle'] = 'Email-based authentication';
$string['auth_fctitle'] = 'Use a FirstClass server';
$string['auth_imapport'] = 'IMAP server port number. Usually this is 143 or 993.';
$string['auth_imaptitle'] = 'Use an IMAP server';
$string['auth_imaptype'] = 'The IMAP server type. IMAP servers can have different types of authentication and negotiation.';
+$string['auth_ldap_server_settings'] = 'LDAP server settings';
+$string['auth_ldap_bind_settings'] = 'Bind settings';
+$string['auth_ldap_user_settings'] = 'User lookup settings';
+$string['auth_ldap_login_settings'] = 'Login settings';
+$string['auth_common_settings'] = 'Common settings';
+$string['auth_data_mapping'] = 'Data mapping';
$string['auth_ldap_bind_dn'] = 'If you want to use bind-user to search users, specify it here. Someting like \'cn=ldapuser,ou=public,o=org\'';
$string['auth_ldap_bind_pw'] = 'Password for bind-user.';
$string['auth_ldap_contexts'] = 'List of contexts where users are located. Separate different contexts with \';\'. For example: \'ou=users,o=org; ou=others,o=org\'';
$string['auth_user_create'] = 'Enable user creation';
$string['auth_user_creation'] = 'New (anonymous) users can create user accounts on the external authentication source and confirmed via email. If you enable this , remember to also configure module-specific options for user creation.';
$string['auth_usernameexists'] = 'Selected username already exists. Please choose a new one.';
+$string['auth_updatelocal'] = 'Update local data';
+$string['auth_updatelocal_expl'] = '<p><b>Update local data:</b> If enabled, the field will be updated (from external auth) every time the user logs in or there is a user synchronization. Fields set to update locally should be locked.</p>';
+$string['auth_updateremote'] = 'Update external data';
+$string['auth_updateremote_expl'] = '<p><b>Update external data:</b> If enabled, the external auth will be updated when the user record is updated. Fields should be unlocked to allow edits.</p>';
+$string['auth_updateremote_ldap'] = '<p><b>Note:</b> Updating external LDAP data requires that you set binddn and bindpw to a bind-user with editing privileges to all the user records. It currently does not preserve multi-valued attributes, and will remove extra values on update. </p>';
$string['authenticationoptions'] = 'Authentication options';
$string['authinstructions'] = 'Here you can provide instructions for your users, so they know which username and password they should be using. The text you enter here will appear on the login page. If you leave this blank then no instructions will be printed.';
$string['changepassword'] = 'Change password URL';
$string['changepasswordhelp'] = 'Here you can specify a location at which your users can recover or change their username/password if they\'ve forgotten it. This will be provided to users as a button on the login page and their user page. if you leave this blank the button will not be printed.';
$string['chooseauthmethod'] = 'Choose an authentication method: ';
-$string['guestloginbutton'] = 'Guest login button';
$string['instructions'] = 'Instructions';
$string['md5'] = 'MD5 encryption';
$string['plaintext'] = 'Plain text';
$string['showguestlogin'] = 'You can hide or show the guest login button on the login page.';
+$string['stdchangepassword'] = 'Use standard Change Password Page';
+$string['stdchangepassword_expl'] = 'If the external authentication system allows password changes through Moodle, switch this to Yes. This setting overrides \'Change Password URL\'.';
+$string['stdchangepassword_explldap'] = 'NOTE: It is recommended that you use LDAP over an SSL encrypted tunnel (ldaps://) if the LDAP server is remote.';
+$string['forcechangepassword'] = 'Force change password';
+$string['forcechangepassword_help'] = 'Force users to change password on their first login to Moodle.';$string['guestloginbutton'] = 'Guest login button';
?>
$string['editfiles'] = 'Edit files';
$string['editgroupprofile'] = 'Edit group profile';
$string['editinga'] = 'Editing $a';
+$string['editlock'] = 'This value cannot be edited!';
$string['editmyprofile'] = 'Edit profile';
$string['editorbgcolor'] = 'Background-color';
$string['editorcleanonpaste'] = 'Clean Word HTML on paste';
set_field('user', 'auth', 'manual', 'username', 'guest');
}
+ /* Commented out unused guid-field code
if ($oldversion < 2004090300) { // Add guid-field used in user syncronization
table_column('user', '', 'guid', 'varchar', '128', '', '', '', 'auth');
execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX authguid (auth, guid)");
}
+ */
+
+ if ($oldversion < 2004091900) { // modify idnumber to hold longer values
+ table_column('user', 'idnumber', 'idnumber', 'varchar', '64', '', '', '', 'auth');
+ execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX idnumber (idnumber)");
+ execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX auth (auth)");
+ }
return $result;
CREATE TABLE `prefix_user` (
`id` int(10) unsigned NOT NULL auto_increment,
`auth` varchar(20) NOT NULL default 'manual',
- `guid` varchar(128) default NULL,
`confirmed` tinyint(1) NOT NULL default '0',
`deleted` tinyint(1) NOT NULL default '0',
`username` varchar(100) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
- `idnumber` varchar(12) default NULL,
+ `idnumber` varchar(64) default NULL,
`firstname` varchar(20) NOT NULL default '',
`lastname` varchar(20) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
UNIQUE KEY `username` (`username`)
) TYPE=MyISAM COMMENT='One record for each person';
-ALTER TABLE `prefix_user` ADD INDEX `authguid` (`auth`, `guid`);
+ALTER TABLE `prefix_user` ADD INDEX `auth` (`auth`);
+ALTER TABLE `prefix_user` ADD INDEX `idnumber` (`idnumber`);
# --------------------------------------------------------
#
set_field('user', 'auth', 'manual', 'username', 'guest');
}
+ /* Just commenteed unused fields out
if ($oldversion < 2004090300) { // Add guid-field used in user syncronization
table_column('user', '', 'guid', 'varchar', '128', '', '', '', 'auth');
execute_sql("CREATE INDEX {$CFG->prefix}user_auth_guid_idx ON {$CFG->prefix}user (auth, guid)");
}
+ */
+ if ($oldversion < 2004091900) { //Modify idnumber to hold longer keys
+ set_field('user', 'auth', 'manual', 'username', 'guest');
+ table_column('user', 'idnumber', 'idnumber', 'varchar', '64', '', '', '', '');
+ execute_sql("CREATE INDEX {$CFG->prefix}user_idnumber_idx ON {$CFG->prefix}user (idnumber)");
+ execute_sql("CREATE INDEX {$CFG->prefix}user_auth_idx ON {$CFG->prefix}user (auth)");
+ }
+
+
return $result;
}
CREATE TABLE prefix_user (
id SERIAL PRIMARY KEY,
auth varchar(20) NOT NULL default 'manual',
- guid varchar(128) default NULL,
confirmed integer NOT NULL default '0',
deleted integer NOT NULL default '0',
username varchar(100) NOT NULL default '',
password varchar(32) NOT NULL default '',
- idnumber varchar(12) default NULL,
+ idnumber varchar(64) default NULL,
firstname varchar(20) NOT NULL default '',
lastname varchar(20) NOT NULL default '',
email varchar(100) NOT NULL default '',
CONSTRAINT prefix_user_username_uk UNIQUE (username)
);
-CREATE INDEX prefix_user_auth_guid_idx ON prefix_user (auth, guid);
+CREATE INDEX prefix_user_idnumber_idx ON prefix_user (idnumber);
+CREATE INDEX prefix_user_auth_idx ON prefix_user (auth);
CREATE TABLE prefix_user_admins (
id SERIAL PRIMARY KEY,
<field name="password" type="C" size="32" default="">\r
<NOTNULL/>\r
</field>\r
- <field name="idnumber" type="C" size="12" default="">\r
+ <field name="idnumber" type="C" size="64" default="">\r
<NOTNULL/>\r
</field>\r
<field name="firstname" type="C" size="20" default="">\r
}
}
-function set_user_preference($name, $value) {
+function set_user_preference($name, $value, $user=NULL) {
/// Sets a preference for the current user
+/// Optionally, can set a preference for a different user object
global $USER;
+ if (empty($user)){
+ $user = $USER;
+ }
+
if (empty($name)) {
return false;
}
- if ($preference = get_record('user_preferences', 'userid', $USER->id, 'name', $name)) {
+ if ($preference = get_record('user_preferences', 'userid', $user->id, 'name', $name)) {
if (set_field("user_preferences", "value", $value, "id", $preference->id)) {
- $USER->preference[$name] = $value;
+ $user->preference[$name] = $value;
return true;
} else {
return false;
}
} else {
- $preference->userid = $USER->id;
+ $preference->userid = $user->id;
$preference->name = $name;
$preference->value = (string)$value;
if (insert_record('user_preferences', $preference)) {
- $USER->preference[$name] = $value;
+ $user->preference[$name] = $value;
return true;
} else {
return false;
die;
}
+ // check whether the user should be changing password
+ reload_user_preferences();
+ if ($USER->preference['auth_forcepasswordchange']){
+ if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
+ redirect("$CFG->wwwroot/login/change_password.php");
+ } elseif($CFG->changepassword) {
+ redirect($CFG->changepassword);
+ } else {
+ error("You cannot proceed without changing your password.
+ However there is no available page for changing it.
+ Please contact your Moodle Administrator.");
+ }
+ }
+
// Check that the user account is properly set up
if (user_not_fully_set_up($USER)) {
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=".SITEID);
$newuser->timemodified = time();
if (insert_record("user", $newuser)) {
- return get_user_info_from_db("username", $username);
+ $user = get_user_info_from_db("username", $newuser->username);
+ if($CFG->{'auth_'.$newuser->auth.'_forcechangepassword'}){
+ set_user_preference('auth_forcepasswordchange', 1, $user);
+ }
+ return $user;
}
return false;
}
+function update_user_record($username) {
+/// will update a local user record from an external source.
+ global $CFG;
+
+ if (function_exists('auth_get_userinfo')) {
+ $username = trim(moodle_strtolower($username)); /// just in case check text case
+
+ if ($newinfo = auth_get_userinfo($username)) {
+ foreach ($newinfo as $key => $value){
+ if (!empty($CFG->{'auth_user_' . $key. '_updatelocal'})) {
+ $value = addslashes(stripslashes($value)); // Just in case
+ set_field('user', $key, $value, 'username', $username);
+ }
+ }
+ }
+ }
+ return get_user_info_from_db("username", $username);
+}
function guest_user() {
global $CFG;
} else {
$auth = $CFG->auth; // Normal users default to site method
}
+ // update user record from external DB
+ if ($user->auth != 'manual' && $user->auth != 'email') {
+ $user = update_user_record($username);
+ }
} else {
$auth = $user->auth;
}
if ($md5password <> $user->password) { // Update local copy of password for reference
set_field('user', 'password', $md5password, 'username', $username);
}
+ // update user record from external DB
+ if ($user->auth != 'manual' && $user->auth != 'email'){
+ $user = update_user_record($username);
+ }
} else {
$user = create_user_record($username, $password, $auth);
}
}
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
\ No newline at end of file
+?>
-<?php // $Id$
+<?PHP // $Id$
require_once("../config.php");
error("Can't change guest password!");
}
- if (set_field("user", "password", $password, "username", $username)) {
- $user->password = $password;
- } else {
- error("Could not set the new password");
+ if(is_internal_auth($user)){
+ if (set_field("user", "password", $password, "username", $username)) {
+ $user->password = $password;
+ } else {
+ error("Could not set the new password");
+ }
+ } else { // external users
+ // the relevant auth libs should be loaded already
+ // as validate_form() calls authenticate_user_login()
+ // check that we allow changes through moodle
+ if(isset($CFG->{'auth_'. $user->auth.'_stdchangepassword'}) && $CFG->{'auth_'. $user->auth.'_stdchangepassword'}){
+ if(function_exists('auth_user_update_password')){
+ // note that we pass cleartext password
+ if(auth_user_update_password($user->username, $frm->newpassword1)){
+ $user->password = $password;
+ } else {
+ error("Could not set the new password");
+ }
+ } else {
+
+ error_log("External Authentication " . $user->auth .
+ ' is set to use standard change password interface ' .
+ ' but auth_user_update_password() is missing.');
+ error('The authentication module is misconfigured');
+ }
+ } else {
+ error("You are cannot change you password this way.");
+ }
}
-
+
+ // register success changing password
+ set_user_preference('auth_forcepasswordchange', false);
+
$USER = $user;
$USER->loggedin = true;
$USER->site = $CFG->wwwroot; // for added security
*****************************************************************************/
function validate_form($frm, &$err) {
- if (empty($frm->username))
+ if (empty($frm->username)){
$err->username = get_string("missingusername");
+ } else {
+ if (empty($frm->password)){
+ $err->password = get_string("missingpassword");
+ } else {
+ //require non adminusers to give valid password
+ if (!isadmin() && !authenticate_user_login($frm->username, $frm->password)){
+ $err->password = get_string("wrongpassword");
+ }
+ }
+ }
- else if (empty($frm->password))
- $err->password = get_string("missingpassword");
-
- else if (!authenticate_user_login($frm->username, $frm->password))
- $err->password = get_string("wrongpassword");
-
- if (empty($frm->newpassword1))
+ if (empty($frm->newpassword1)){
$err->newpassword1 = get_string("missingnewpassword");
+ }
- if (empty($frm->newpassword2))
+ if (empty($frm->newpassword2)){
$err->newpassword2 = get_string("missingnewpassword");
-
- else if ($frm->newpassword1 <> $frm->newpassword2)
- $err->newpassword2 = get_string("passwordsdiffer");
-
+ } else {
+ if ($frm->newpassword1 <> $frm->newpassword2) {
+ $err->newpassword2 = get_string("passwordsdiffer");
+ } else {
+ if($frm->password === $frm->newpassword1){
+ $err->newpassword1 = get_string("mustchangepassword");
+ }
+ }
+ }
+
return;
}
?>\r
<form action="change_password.php" method="post" name="form" id="form">\r
<table cellpadding="10">\r
+\r
<tr valign="top">\r
<td><p><?php print_string("username") ?>:</p></td>\r
- <td><input type="text" name="username" size="25" value="<?php p($frm->username) ?>" />\r
+ <td>\r
+ <?php if (isadmin()) { ?>\r
+ <input type="text" name="username" size="25" value="<?php p($frm->username) ?>" />\r
+ <?php } else { ?>\r
+ <input type="hidden" name="username" value="<?php p($frm->username)?>" /> <?php p($frm->username)?>\r
+ <?php } ?>\r
<?php if (!empty($err->username)) { formerr($err->username); } ?>\r
</td>\r
</tr>\r
-<tr valign="top">\r
- <td><p><?php print_string("password") ?>:</p></td>\r
- <td><input type="password" name="password" size="25" value="<?php p($frm->password) ?>" />\r
- <?php if (!empty($err->password)) { formerr($err->password); } ?>\r
- </td>\r
-</tr>\r
+\r
+<?php if (!isadmin()) { ?>\r
+ <tr valign="top">\r
+ <td><p><?php print_string("password") ?>:</p></td>\r
+ <td><input type="password" name="password" size="25" value="<?php p($frm->password) ?>" />\r
+ <?php if (!empty($err->password)) { formerr($err->password); } ?>\r
+ </td>\r
+ </tr>\r
+<?php } ?>\r
+\r
<tr valign="top">\r
<td><p><?php print_string("newpassword") ?>:</p></td>\r
<td><input type="password" name="newpassword1" size="25" value="<?php p($frm->newpassword1) ?>" />\r
unset($SESSION->lang);
$SESSION->justloggedin = true;
+ // check whether the user should be changing password
+ reload_user_preferences();
+ if ($USER->preference['auth_forcepasswordchange']){
+ if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
+ redirect("$CFG->wwwroot/login/change_password.php");
+ } elseif($CFG->changepassword) {
+ redirect($CFG->changepassword);
+ } else {
+ error("You cannot proceed without changing your password.
+ However there is no available page for changing it.
+ Please contact your Moodle Administrator.");
+ }
+ }
+
if (user_not_fully_set_up($USER)) {
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=".SITEID);
$auth_options[$module] = get_string("auth_$module"."title", "auth");
}
echo '<tr valign="top">';
- echo '<td align="right">' . get_string("chooseauthmethod","auth") . ':</td>' . "\n<td>";
- choose_from_menu ($auth_options, "auth",$user->auth);
+ echo '<td align="right">'.get_string("chooseauthmethod","auth").'</td>' . "\n<td>";
+ choose_from_menu ($auth_options, "auth", $user->auth);
echo "</td></tr>\n";
- if ($adminself || is_internal_auth($user->auth) ){
+ if ($adminself || is_internal_auth($user->auth) || (!empty($CFG->{'auth_'.$user->auth.'_stdchangepassword'}))) {
echo "<tr valign=\"top\">";
echo "<td align=\"right\"> ".get_string("newpassword").": </td>";
echo "<td> <input type=\"text\" name=\"newpassword\" size=\"20\" value=\"";
}
echo " </td>";
echo "</tr>\n";
+ if(!$adminself && ($CFG->{'auth_'.$user->auth.'_stdchangepassword'} || $CFG->changepassword)){
+ echo "<tr>";
+ echo '<td align=right><p>'.get_string('forcepasswordchange').':</td>';
+ echo '<td><input type="checkbox" name="forcepasswordchange" />'.get_string('forcepasswordchange_help').'</td>';
+ echo "</tr>";
+ }
+
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
}
}
?>
<tr valign="top">
<td align="right"><?php print_string("firstname") ?>:</td>
- <td><input type="text" name="firstname" size="30" maxlength="20" value="<?php p($user->firstname) ?>" />
+ <td>
+ <?php if ($user_external && $CFG->auth_user_firstname_editlock){ ?>
+ <input type="hidden" name="firstname" value="<?php p($user->firstname) ?>" />
+ <?php p($user->firstname) ?>
+ <?php } else { ?>
+ <input type="text" name="firstname" size="30" maxlength="20" value="<?php p($user->firstname) ?>" />
+ <?php } ?>
<?php if (isset($err["firstname"])) formerr($err["firstname"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><?php print_string("lastname") ?>:</td>
- <td><input type="text" name="lastname" size="30" maxlength="20" value="<?php p($user->lastname) ?>" />
+ <td>
+ <?php if($user_external && $CFG->auth_user_lastname_editlock){ ?>
+ <input type="hidden" name="lastname" value="<?php p($user->lastname) ?>" />
+ <?php p($user->lastname) ?>
+ <?php } else { ?>
+ <input type="text" name="lastname" size="30" maxlength="20" value="<?php p($user->lastname) ?>" />
+ <?php } ?>
<?php if (isset($err["lastname"])) formerr($err["lastname"]); ?>
</td>
</tr>
<tr valign="top">
- <td align="right"><?php print_string("email") ?>:</td>
- <td><input type="text" name="email" size="30" maxlength="100" value="<?php p($user->email) ?>" />
+ <td align="right"><p><?php print_string("email") ?>:</td>
+ <td>
+ <?php if($user_external && $CFG->auth_user_email_editlock){ ?>
+ <input type="hidden" name="email" value="<?php p($user->email) ?>" />
+ <?php p($user->email) ?>
+ <?php } else { ?>
+ <input type="text" name="email" size="30" maxlength="100" value="<?php p($user->email) ?>" />
+ <?php } ?>
<?php if (isset($err["email"])) formerr($err["email"]); ?>
</td>
</tr>
</tr>
<?php } ?>
<tr valign="top">
- <td align="right"> <?php print_string("city") ?>: </td>
- <td><input type="text" name="city" size="25" maxlength="20" value="<?php p($user->city) ?>" />
+ <td align="right"> <?php print_string("city") ?>:</td>
+ <td>
+ <?php if($user_external && $CFG->auth_user_city_editlock){ ?>
+ <input type="hidden" name="city" value="<?php p($user->city) ?>" />
+ <?php p($user->city) ?>
+ <?php } else { ?>
+ <input type="text" name="city" size="25" maxlength="20" value="<?php p($user->city) ?>" />
+ <?php } ?>
<?php if (isset($err["city"])) formerr($err["city"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("country") ?>: </td>
- <td> <?php
+ <td>
+ <?php
if (!$user->country and $CFG->country) {
$user->country = $CFG->country;
}
- choose_from_menu (get_list_of_countries(), "country", $user->country, get_string("selectacountry")."...", "", "") ?>
+ if($user_external && $CFG->auth_user_country_editlock){ ?>
+ <input type="hidden" name="country" value="<?php p($user->country); ?>" />
+ <?php p($user->country);
+ } else {
+ choose_from_menu(get_list_of_countries(), "country", $user->country, get_string("selectacountry")."...", "", "");
+ }
+ ?>
<?php if (isset($err["country"])) formerr($err["country"]); ?>
</td>
</tr>
if (!$user->lang) {
$user->lang = $CFG->lang;
}
- choose_from_menu ($languages, "lang", $user->lang, "", "", "");
+ if($user_external && $CFG->auth_user_lang_editlock){ ?>
+ <input type="hidden" name="lang" value="<?php p($user->lang) ?>" />
+ <?php p($user->lang);
+ } else {
+ choose_from_menu ($languages, "lang", $user->lang, "", "", "");
+ }
}
if (isset($err["lang"])) formerr($err["lang"]);
?>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("userdescription") ?>: </td>
- <td> <?php
+ <td><?php if (isset($err["description"])) {
+ formerr($err["description"]);
+ echo "<br />";
+ } ?>
+ <?php if($user_external && $CFG->auth_user_description_editlock){ ?>
+ <input type="hidden" name="description" value="<?php p($user->description) ?>" />
+ <?php print format_text($user->description, FORMAT_MOODLE);
+ } else {
if (isset($err["description"])) {
formerr($err["description"]);
echo "<br />";
}
print_textarea(false, 10, 50, 50, 10, 'description', "$user->description");
helpbutton("text", get_string("helptext"));
- ?>
- </td>
+
+ } ?>
+ </td>
</tr>
<tr>
<td colspan="2" align="center"> <br /><b><?php print_string("followingoptional") ?>:</b> </td>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("idnumber") ?>: </td>
- <td> <input type="text" name="idnumber" size="25" maxlength="12" value="<?php p($user->idnumber) ?>" /> <?php p($teacheronly) ?>
+ <td>
+ <?php if($user_external && $CFG->auth_user_idnumber_editlock){ ?>
+ <input type="hidden" name="idnumber" value="<?php p($user->idnumber) ?>" />
+ <?php p($user->idnumber) ?>
+ <?php } else { ?>
+ <input type="text" name="idnumber" size="25" maxlength="12" value="<?php p($user->idnumber) ?>" /> <?php p($teacheronly) ?>
+ <?php } ?>
<?php if (isset($err["idnumber"])) formerr($err["idnumber"]); ?>
</td>
</tr>
<?php if (isadmin()) { ?>
<tr valign="top">
- <td align="right"> <?php print_string("institution") ?>: </td>
- <td> <input type="text" name="institution" size="25" maxlength="40" value="<?php p($user->institution) ?>" /> <?php p($teacheronly) ?>
- </td>
+ <td align="right"> <?php print_string("institution") ?>:</td>
+ <td><input type="text" name="institution" size="25" maxlength="40" value="<?php p($user->institution) ?>" /> <?php p($teacheronly) ?>
+ </td>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("department") ?>: </td>
- <td> <input type="text" name="department" size="25" maxlength="30" value="<?php p($user->department) ?>" /> <?php p($teacheronly) ?>
- </td>
+ <td>
+ <?php if($user_external && $CFG->auth_user_department_editlock){ ?>
+ <input type="hidden" name="department" value="<?php p($user->department) ?>" />
+ <?php p($user->department) ?>
+ <?php } else { ?>
+ <input type="text" name="department" size="25" maxlength="30" value="<?php p($user->department) ?>" /> <?php p($teacheronly) ?>
+ <?php } ?>
+ </td>
</tr>
<?php } ?>
<tr valign="top">
<td align="right"> <?php print_string("phone") ?> 1: </td>
- <td> <input type="text" name="phone1" size="25" maxlength="20" value="<?php p($user->phone1) ?>" /> <?php p($teacheronly) ?>
+ <td>
+ <?php if($user_external && $CFG->auth_user_phone1_editlock){ ?>
+ <input type="hidden" name="phone1" value="<?php p($user->phone1) ?>" />
+ <?php p($user->phone1) ?>
+ <?php } else { ?>
+ <input type="text" name="phone1" size="25" maxlength="20" value="<?php p($user->phone1) ?>" /> <?php p($teacheronly) ?>
+ <?php } ?>
<?php if (isset($err["phone1"])) formerr($err["phone1"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("phone") ?> 2: </td>
- <td> <input type="text" name="phone2" size="25" maxlength="20" value="<?php p($user->phone2) ?>"/> <?php p($teacheronly) ?>
+ <td>
+ <?php if($user_external && $CFG->auth_user_phone2_editlock){ ?>
+ <input type="hidden" name="phone2" value="<?php p($user->phone2) ?>" />
+ <?php p($user->phone2) ?>
+ <?php } else { ?>
+ <input type="text" name="phone2" size="25" maxlength="20" value="<?php p($user->phone2) ?>" /> <?php p($teacheronly) ?>
+ <?php } ?>
<?php if (isset($err["phone2"])) formerr($err["phone2"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"> <?php print_string("address") ?>: </td>
- <td> <input type="text" name="address" size="25" maxlength="70" value="<?php p($user->address) ?>" /> <?php p($teacheronly) ?>
+ <td>
+ <?php if($user_external && $CFG->auth_user_address_editlock){ ?>
+ <input type="hidden" name="address" value="<?php p($user->address) ?>" />
+ <?php p($user->address) ?>
+ <?php } else { ?>
+ <input type="text" name="address" size="25" maxlength="70" value="<?php p($user->address) ?>" /> <?php p($teacheronly) ?>
+ <?php } ?>
<?php if (isset($err["address"])) formerr($err["address"]); ?>
</td>
</tr>
error("Sorry, the guest user cannot be edited.");
}
+ // load the relevant auth libraries
+ if ($user->auth) {
+ $auth = $user->auth;
+ if (!file_exists("$CFG->dirroot/auth/$auth/lib.php")) {
+ $auth = "manual"; // Can't find auth module, default to internal
+ }
+ require_once("$CFG->dirroot/auth/$auth/lib.php");
+ }
+
/// If data submitted, then process and store.
if ($usernew = data_submitted()) {
require_once($CFG->dirroot.'/lib/uploadlib.php');
$um = new upload_manager('imagefile',false,false,null,false,0,true,true);
- if (find_form_errors($user, $usernew, $err,$um)) {
+ if (find_form_errors($user, $usernew, $err, $um)) {
if (empty($err['imagefile']) && $usernew->picture = save_profile_image($user->id, $um,'users')) {
set_field('user', 'picture', $usernew->picture, 'id', $user->id); /// Note picture in DB
} else {
if (isadmin()) {
if (!empty($usernew->newpassword)) {
$usernew->password = md5($usernew->newpassword);
+ // update external passwords
+ if (!empty($CFG->{'auth_'. $user->auth.'_stdchangepassword'})) {
+ if(function_exists('auth_user_update_password')){
+ if (!auth_user_update_password($user->username, $usernew->newpassword)){
+ error('Failed to update password on external auth: ' . $user->auth .
+ '. See the server logs for more details.');
+ }
+ } else {
+ error('Your external authentication module is misconfigued!');
+ }
+ }
+ // store forcepasswordchange in user's preferences
+ if (isset($usernew->forcepasswordchange)){
+ set_user_preference('auth_forcepasswordchange', 1, $user);
+ }
}
} else {
if (isset($usernew->newpassword)) {
}
if (update_record("user", $usernew)) {
- add_to_log($course->id, "user", "update", "view.php?id=$user->id&course=$course->id", "");
+ if (function_exists("auth_user_update")){
+ auth_user_update($user, $usernew);
+ }
+ add_to_log($course->id, "user", "update", "view.php?id=$user->id&course=$course->id", "");
if ($user->id == $USER->id) {
// Copy data into $USER session variable
print_simple_box_start("center", "", "$THEME->cellheading");
if (!empty($err)) {
- echo "<center>";
- notify(get_string("someerrorswerefound"));
- echo "</center>";
+ echo "<center>";
+ notify(get_string("someerrorswerefound"));
+ echo "</center>";
}
include("edit.html");
print_simple_box_end();
$err["username"] = get_string("missingusername");
} else if (record_exists("user", "username", $usernew->username) and $user->username == "changeme") {
- $err["username"] = get_string("usernameexists");
+ $err["username"] = get_string("usernameexists");
} else {
if (empty($CFG->extendedusernamechars)) {
$err['imagefile'] = $um->notify;
}
+ if ($CFG->auth_user_firstname_editlock && !($user->firstname === $usernew->firstname)){
+ $err["firstname"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_lastname_editlock && !($user->lastname === $usernew->lastname)){
+ $err["lastname"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_email_editlock && !($user->email === $usernew->email)){
+ $err["email"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_phone1_editlock && !($user->phone1 === $usernew->phone1)){
+ $err["phone1"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_phone2_editlock && !($user->phone2 === $usernew->phone2)){
+ $err["phone2"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_department_editlock && !($user->department === $usernew->department)){
+ $err["department"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_address_editlock && !($user->address === $usernew->address)){
+ $err["address"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_city_editlock && !($user->city === $usernew->city)){
+ $err["city"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_description_editlock && !($user->description === $usernew->description)){
+ $err["description"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_idnumber_editlock && !($user->idnumber === $usernew->idnumber)){
+ $err["idnumber"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_lang_editlock && !($user->lang === $usernew->lang)){
+ $err["lang"] = get_string("editlock");
+ }
+ if ($CFG->auth_user_guid_editlock && !($user->guid === $usernew->guid)){
+ $err["guid"] = get_string("editlock");
+ }
+
$user->email = $usernew->email;
return count($err);
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2004091700; // The current version is a date (YYYYMMDDXX)
+$version = 2004091900; // The current version is a date (YYYYMMDDXX)
$release = "1.5 unstable development"; // User-friendly version number