help logoLON-CAPA Help


Format restrictions for usernames and student/employeeIDs for an institution, and formats which may not be used for e-mail addresses used as usernames when users self-create accounts are defined in three subroutines in localenroll.pm: username_rules(), id_rules(), and selfcreate_rules(). The three routines accept a similar set of arguments, and return 'ok' in each case, if no error occurred.

username_rules - Incoming data: three arguments

  1. $dom - domain

  2. $ruleshash - reference to hash containing rules (a hash of a hash)

    keys of top level hash are short names (e.g., netid, noncredit); for each key, value is a hash.

  3. $rulesorder - reference to array containing rule names in order to be displayed

At MSU, a NetID consists of eight characters or less, and will be authenticated by Kerberos (version 5) in the MSU.EDU realm. The rule itself is defined in username_rules(), and the code which checks for compliance is in username_check():

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.',

}
);

@{$rulesorder} = ('netid');

return 'ok';

}
id_rules - Incoming data: three arguments

  1. $dom - domain

  2. $ruleshash - reference to hash containing rules (a hash of a hash)keys of top level hash are short names (e.g., studentID, employeeID); for each key, value is a hash

  3. $rulesorder - reference to array containing rule names in order to be displayed

At MSU, student/employee IDs are eight digits prefaced by A or Z. The rule itself is defined in id_rules(), and the code which checks for compliance is in id_check():

sub id_rules {
my ($dom,$ruleshash,$rulesorder) = @_;

%{$ruleshash} = (

studentID => {
name => 'MSU student PID',

desc => 'Letter A or a, followed by eight digits',

},

facstaffID = > {

name => 'MSU faculty/staff ID',

desc => 'Letter Z or z, followed by eight digits',

},
);

@{$rulesorder} = ('studentID','facstaffID');

return 'ok';

}
selfcreate_rules - Incoming data: three arguments

  1. $dom - domain

  2. $ruleshash - reference to hash containing rules (a hash of a hash)

    keys of top level hash are short names (e.g., msuemail); for each key, value is a hash

  3. $rulesorder - reference to array containing rule names in order to be displayed

At MSU all users receive a Net ID (e.g., sparty), and a corresponding e-mail account: sparty@msu.edu. So, at MSU the rules for e-mail addresses to be used as LON-CAPA usernames prohibit e-mails such as sparty@msu.edu. In such cases, the user should log-in with the sparty Net ID/password and request account creation for the username: sparty. The rule itself is defined in selfcreate_rules(), and the code which checks for compliance is in selfcreate_check():

sub selfcreate_rules {
my ($dom,$ruleshash,$rulesorder) = @_;

%{$ruleshash} = (

msuemail => {

name => 'MSU e-mail address ',

desc => 'netid@msu.edu',

},

);

@{$rulesorder} = ('msuemail');

return 'ok';

}
The corresponding routines which check for compliance with rules enabled via Domain Configuration- > User Creation are username_check(), id_check(), and selfcreate_check(). The three routines accept a similar set of four arguments, and return 'ok' in each case, if no error occurred.

  1. $dom - domain (scalar)

  2. $uname (username_check()), $id (id_check()) or $selfcreatename (selfcreate_check())

    - proposed username, id or self-created username being compared against rules (scalar)

  3. $to_check (reference to array of rule names to check)

  4. $resultshash (reference to hash of results) hash of results for rule checked

    keys are rule names - values are: 1 or 0 (for matched or unmatched)

The routines used for checking rule compliance at MSU are as follows:

username_check

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;
}
}

$outcome = 'ok';

}

return $outcome;

}
id_check

sub id_check {
my ($dom,$id,$to_check,$resultshash) = @_;

my $outcome;

if (ref($to_check) eq 'ARRAY') {

foreach my $item (@{$to_check}) {
if ($item eq 'facstaffID') {
if ($id =~ /^z\d{8}$/i) {
$resultshash->{$item} = 1;
} else {
$resultshash->{$item} = 0;
}
} elsif ($item eq 'studentID') {
if ($id =~ /^a\d{8}$/i) {
$resultshash->{$item} = 1;
} else {
$resultshash->{$item} = 0;
}
}
}

$outcome = 'ok';

}

return $outcome;

}
selfcreate_check

sub selfcreate_check {
my ($dom,$selfcreatename,$to_check,$resultshash) = @_;

my $outcome;

if (ref($to_check) eq 'ARRAY') {

foreach my $item (@{$to_check}) {
if ($item eq 'msuemail') {
if ($selfcreatename =~ /^\w{2,8}\@msu\.edu$/) {
$resultshash->{$item} = 1;
} else {
$resultshash->{$item} = 0;
}
}
}

$outcome = 'ok';

}

return $outcome;

}