[LON-CAPA-cvs] cvs: modules /msu localenroll.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 12 Sep 2007 19:59:57 -0000
raeburn Wed Sep 12 15:59:57 2007 EDT
Modified files:
/modules/msu localenroll.pm
Log:
MSU implementation of &username_rules() and &username_check().
- Format rule for MSU NetID as username.
- Format rule for e-mail address as username (for future non-credit enrollment system).
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.29 modules/msu/localenroll.pm:1.30
--- modules/msu/localenroll.pm:1.29 Sat Aug 25 14:49:57 2007
+++ modules/msu/localenroll.pm Wed Sep 12 15:59:55 2007
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.29 2007/08/25 18:49:57 raeburn Exp $
+# $Id: localenroll.pm,v 1.30 2007/09/12 19:59:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -503,6 +503,7 @@
StuAff => 'STUDENT_AFFILIATE');
my ($dbh,$dbflag) = &connect_DB('HR');
if ($dbflag) {
+ $outcome = 'ok';
foreach my $type (@{$types}) {
if (exists($tables{$type})) {
push(@srchtables,$tables{$type});
@@ -525,7 +526,6 @@
if ($srchterm ne '') {
&query_user_tables($dbh,\@srchtables,$instusers,$instids,
$srchby,$srchterm,$srchtype);
- $outcome = 'ok';
}
&disconnect_DB($dbh);
}
@@ -660,6 +660,54 @@
return $outcome;
}
+sub username_rules {
+ my ($dom,$ruleshash,$rulesorder) = @_;
+ %{$ruleshash} = (
+ netid => {
+ name => 'MSU NetID',
+ desc => 'Eight characters or less',
+ authtype => 'krb5',
+ authparm => 'MSU.EDU',
+ authparmfixed => '',
+ authmsg => 'A new user with a username which matches a valid MSU NetID will log-in using the MSU Net ID and MSU Net password.',
+ },
+ noncred => {
+ name => 'MSU non-credit registration',
+ desc => 'Valid e-mail address: a single @, with least one character (non-@) both before and after the @',
+ authtype => 'int',
+ authparm => '',
+ authparmfixed => '',
+ authmsg => 'A new user with a username which matches a valid MSU guest ID will log-in using the full e-mail address as username, and the password they have chosen.',
+ },
+ );
+ @{$rulesorder} = ('netid','noncred');
+ return 'ok';
+}
+
+sub username_check {
+ my ($dom,$uname,$to_check,$resultshash) = @_;
+ my $outcome;
+ if (ref($to_check) eq 'ARRAY') {
+ foreach my $item (@{$to_check}) {
+ if ($item eq 'netid') {
+ if ($uname =~ /^\w{2,8}$/) {
+ $resultshash->{$item} = 1;
+ } else {
+ $resultshash->{$item} = 0;
+ }
+ } elsif ($item eq 'noncred') {
+ if ($uname =~ /^[^\@]+\@[^\@]+$/) {
+ $resultshash->{$item} = 1;
+ } else {
+ $resultshash->{$item} = 0;
+ }
+ }
+ }
+ $outcome = 'ok';
+ }
+ return $outcome;
+}
+
###############################
# sub AUTOLOAD
#