Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaks to authentication system. Database method now allows other

fields to be specified so that things like email, names etc can be
pulled in from external database when new Moodle accounts are created
  • Loading branch information...
commit 34daec9b3b8a3f4fcfe2db97e4e3b43097be6db5 1 parent 780db23
moodler authored
View
4 admin/auth.php
@@ -104,7 +104,9 @@
require("$CFG->dirroot/auth/$auth/config.html");
echo "<tr valign=\"top\">";
- echo "<td align=right><p>guestloginbutton:</p></td>";
+ echo "<td align=right nowrap><p>";
+ print_string("guestloginbutton", "auth");
+ echo ":</p></td>";
echo "<td>";
choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
echo "</td>";
View
106 auth/db/config.html
@@ -1,4 +1,4 @@
-<tr valign="top">
+<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbhost:</TD>
<TD>
<INPUT name=auth_dbhost TYPE=text SIZE=30 VALUE="<?=$config->auth_dbhost?>">
@@ -9,7 +9,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbtype:</TD>
<TD>
<? $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
@@ -22,7 +22,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbname:</TD>
<TD>
<INPUT name=auth_dbname TYPE=text SIZE=30 VALUE="<?=$config->auth_dbname?>">
@@ -33,7 +33,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbuser:</TD>
<TD>
<INPUT name=auth_dbuser TYPE=text SIZE=30 VALUE="<?=$config->auth_dbuser?>">
@@ -44,7 +44,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbpass:</TD>
<TD>
<INPUT name="auth_dbpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbpass?>">
@@ -55,7 +55,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbtable:</TD>
<TD>
<INPUT name="auth_dbtable" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbtable?>">
@@ -66,7 +66,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbfielduser:</TD>
<TD>
<INPUT name="auth_dbfielduser" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfielduser?>">
@@ -77,7 +77,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbfieldpass:</TD>
<TD>
<INPUT name="auth_dbfieldpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfieldpass?>">
@@ -88,8 +88,96 @@
</TD>
</TR>
+<TR>
+ <TD ALIGN=RIGHT><P><? print_string("firstname") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_firstname?>">
+ </TD>
+ <TD rowspan=12 VALIGN=CENTER>
+ <? print_string("auth_dbextrafields","auth") ?>
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("lastname") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_lastname?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("email") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_email?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("phone") ?> 1:</TD>
+ <TD>
+ <INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_phone1?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("phone") ?> 2:</TD>
+ <TD>
+ <INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_phone2?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("department") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_department?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("address") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_address?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("city") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_city?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("country") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_country?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("description") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_description?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("idnumber") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_idnumber?>">
+ </TD>
+</TR>
+
+<TR VALIGN=TOP>
+ <TD ALIGN=RIGHT><P><? print_string("language") ?>:</TD>
+ <TD>
+ <INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?=$config->auth_user_lang?>">
+ </TD>
+</TR>
+
+
<TR VALIGN=TOP>
- <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+ <TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
<TD>
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
</TD>
View
31 auth/db/lib.php
@@ -32,4 +32,35 @@ function auth_user_login ($username, $password) {
}
+function auth_get_userinfo($username){
+// Reads any other information for a user from external database,
+// then returns it in an array
+
+ global $CFG;
+ $config = (array) $CFG;
+
+ ADOLoadCode($CFG->auth_dbtype);
+ $authdb = &ADONewConnection();
+ $authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
+
+ $fields = array("firstname", "lastname", "email", "phone1", "phone2",
+ "department", "address", "city", "country", "description",
+ "idnumber", "lang");
+
+ $result = array();
+
+ foreach ($fields as $field) {
+ if ($config["auth_user_$field"]) {
+ if ($rs = $authdb->Execute("SELECT ".$config["auth_user_$field"]." FROM $CFG->auth_dbtable
+ WHERE $CFG->auth_dbfielduser = '$username'")) {
+ if ( $rs->RecordCount() == 1 ) {
+ $result["$field"] = $rs->fields[$config["auth_user_$field"]];
+ }
+ }
+ }
+ }
+
+ return $result;
+}
+
?>
View
8 auth/imap/config.html
@@ -1,4 +1,4 @@
-<tr valign="top">
+<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_imaphost:</TD>
<TD>
<INPUT name=auth_imaphost TYPE=text SIZE=30 VALUE="<?=$config->auth_imaphost?>">
@@ -9,7 +9,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_imaptype:</TD>
<TD>
<? $imaptypes = array("imap","imapssl", "imapcert", "imaptls");
@@ -21,7 +21,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_imapport:</TD>
<TD>
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_imapport?>">
@@ -33,7 +33,7 @@
</TR>
<TR VALIGN=TOP>
- <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+ <TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
<TD>
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
</TD>
View
2  auth/ldap/config.html
@@ -63,7 +63,7 @@
</TR>
<TR VALIGN=TOP>
- <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+ <TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
<TD>
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
</TD>
View
6 auth/nntp/config.html
@@ -1,4 +1,4 @@
-<tr valign="top">
+<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_nntphost:</TD>
<TD>
<INPUT name="auth_nntphost" TYPE="text" SIZE=30 VALUE="<?=$config->auth_nntphost?>">
@@ -9,7 +9,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_nntpport:</TD>
<TD>
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
@@ -21,7 +21,7 @@
</TR>
<TR VALIGN=TOP>
- <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+ <TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
<TD>
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
</TD>
View
8 auth/pop3/config.html
@@ -1,4 +1,4 @@
-<tr valign="top">
+<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_pop3host:</TD>
<TD>
<INPUT name=auth_pop3host TYPE=text SIZE=30 VALUE="<?=$config->auth_pop3host?>">
@@ -9,7 +9,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_pop3type:</TD>
<TD>
<? $pop3types = array("pop3","pop3cert");
@@ -22,7 +22,7 @@
</TD>
</TR>
-<TR VALIGN=TOP>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_pop3port:</TD>
<TD>
<INPUT name=auth_pop3port TYPE=text SIZE=6 VALUE="<?=$config->auth_pop3port?>">
@@ -34,7 +34,7 @@
</TR>
<TR VALIGN=TOP>
- <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+ <TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
<TD>
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
</TD>
View
82 lang/en/auth.php
@@ -1,22 +1,26 @@
-<?PHP
-$string['showguestlogin'] = "You can hide or show the guest login button on the login page.";
-$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.";
+<?PHP // $Id$
+ // auth.php - created with Moodle 1.0.6.4 beta (2002112001)
-$string['chooseauthmethod'] = "Choose an authentication method: ";
-$string['auth_emailtitle'] = "Email-based authentication";
+$string['auth_dbdescription'] = "This method uses an external database table to check whether a given username and password is valid.";
+$string['auth_dbextrafields'] = "These fields are optional. You can choose to pre-fill some Moodle user fields with information from the <B>external database fields</B> that you specify here. <P>If you leave these blank, then defaults will be used.<P>In either case, the user will be able to edit all of these fields after they log in.";
+$string['auth_dbfieldpass'] = "Name of the field containing passwords";
+$string['auth_dbfielduser'] = "Name of the field containing usernames";
+$string['auth_dbhost'] = "The computer hosting the database server.";
+$string['auth_dbname'] = "Name of the database itself";
+$string['auth_dbpass'] = "Password matching the above username";
+$string['auth_dbtable'] = "Name of the table in the database";
+$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_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.";
-
-$string['auth_nonetitle'] = "No authentication";
-$string['auth_nonedescription'] = "Users can sign in and create valid accounts immediately, with no authentication against an external server and no confirmation via email. Be careful using this option - think of the security and administration problems this could cause.";
-
-$string['auth_ldaptitle'] = "Use an LDAP server";
-$string['auth_ldapdescription'] = "This method provides authentication against an external LDAP server.
- If the given username and password are valid, Moodle creates a new user
- entry in its database. This module can read user attributes from LDAP and prefill
- wanted fields in Moodle. For following logins only the username and
- password are checked.";
+$string['auth_emailtitle'] = "Email-based authentication";
+$string['auth_imapdescription'] = "This method uses an IMAP server to check whether a given username and password is valid.";
+$string['auth_imaphost'] = "The IMAP server address. Use the IP number, not DNS name.";
+$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['instructions'] = "Instructions";
$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'";
@@ -24,33 +28,27 @@
$string['auth_ldap_search_sub'] = "Put value &lt;&gt; 0 if you like to search users from subcontexts.";
$string['auth_ldap_update_userinfo'] = "Update user information (firstname, lastname, address..) from LDAP to Moodle. Look at /auth/ldap/attr_mappings.php for mapping information";
$string['auth_ldap_user_attribute'] = "The attribute used to name/search users. Usually 'cn'.";
-
-$string['auth_imaptitle'] = "Use an IMAP server";
-$string['auth_imapdescription'] = "This method uses an IMAP server to check whether a given username and password is valid.";
-$string['auth_imaphost'] = "The IMAP server address. Use the IP number, not DNS name.";
-$string['auth_imaptype'] = "The IMAP server type. See the help page (above) for more details.";
-$string['auth_imapport'] = "IMAP server port number. Usually this is 143 or 993.";
-
-$string['auth_dbtitle'] = "Use an external database";
-$string['auth_dbdescription'] = "This method uses an external database table to check whether a given username and password is valid.";
-$string['auth_dbhost'] = "The computer hosting the database server.";
-$string['auth_dbtype'] = "The database type (See the <A HREF=../lib/adodb/readme.htm#drivers>ADOdb documentation</A> for details)";
-$string['auth_dbname'] = "Name of the database itself";
-$string['auth_dbuser'] = "Username with read access to the database";
-$string['auth_dbpass'] = "Password matching the above username";
-$string['auth_dbtable'] = "Name of the table in the database";
-$string['auth_dbfielduser'] = "Name of the field containing usernames";
-$string['auth_dbfieldpass'] = "Name of the field containing passwords";
-
-$string['auth_nntptitle'] = "Use an NNTP server";
+$string['auth_ldapdescription'] = "This method provides authentication against an external LDAP server.
+ If the given username and password are valid, Moodle creates a new user
+ entry in its database. This module can read user attributes from LDAP and prefill
+ wanted fields in Moodle. For following logins only the username and
+ password are checked.";
+$string['auth_ldaptitle'] = "Use an LDAP server";
$string['auth_nntpdescription'] = "This method uses an NNTP server to check whether a given username and password is valid.";
-$string['auth_nntphost'] = "The NNTP server address. Use the IP number, not DNS name.";
-$string['auth_nntpport'] = "Server port (119 is the most common)";
-
-$string['auth_pop3title'] = "Use a POP3 server";
+$string['auth_nntphost'] = "The NNTP server address. Use the IP number, not DNS name.";
+$string['auth_nntpport'] = "Server port (119 is the most common)";
+$string['auth_nntptitle'] = "Use an NNTP server";
+$string['auth_nonedescription'] = "Users can sign in and create valid accounts immediately, with no authentication against an external server and no confirmation via email. Be careful using this option - think of the security and administration problems this could cause.";
+$string['auth_nonetitle'] = "No authentication";
$string['auth_pop3description'] = "This method uses a POP3 server to check whether a given username and password is valid.";
-$string['auth_pop3host'] = "The POP3 server address. Use the IP number, not DNS name.";
-$string['auth_pop3type'] = "Server type. If your server uses certificate security, choose pop3cert.";
-$string['auth_pop3port'] = "Server port (110 is the most common)";
+$string['auth_pop3host'] = "The POP3 server address. Use the IP number, not DNS name.";
+$string['auth_pop3port'] = "Server port (110 is the most common)";
+$string['auth_pop3title'] = "Use a POP3 server";
+$string['auth_pop3type'] = "Server type. If your server uses certificate security, choose pop3cert.";
+$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['chooseauthmethod'] = "Choose an authentication method: ";
+$string['guestloginbutton'] = "Guest login button";
+$string['showguestlogin'] = "You can hide or show the guest login button on the login page.";
?>
View
2  lang/en/moodle.php
@@ -106,6 +106,7 @@
$string['deletedcourse'] = "\$a has been completely deleted";
$string['deletednot'] = "Could not delete \$a !";
$string['deletingcourse'] = "Deleting \$a";
+$string['department'] = "Department";
$string['description'] = "Description";
$string['displayingusers'] = "Displaying users \$a->start to \$a->end";
$string['documentation'] = "Moodle Documentation";
@@ -230,6 +231,7 @@
$string['invalidemail'] = "Invalid email address";
$string['langltr'] = "Language direction left-to-right";
$string['langrtl'] = "Language direction right-to-left";
+$string['language'] = "Language";
$string['languagegood'] = "This language pack is up-to-date! :-)";
$string['lastaccess'] = "Last access";
$string['lastedited'] = "Last edited";
View
2  lib/moodlelib.php
@@ -1403,7 +1403,7 @@ function create_user_record($username, $password) {
if ($CFG->auth_update_userinfo and function_exists(auth_get_userinfo)) {
if ($newinfo = auth_get_userinfo($username)) {
- foreach ($newinfo as $key=>$value){
+ foreach ($newinfo as $key => $value){
$newuser->$key = $value;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.