[LON-CAPA-cvs] cvs: loncom / lond
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 10 Nov 2007 03:38:31 -0000
raeburn Fri Nov 9 22:38:31 2007 EDT
Modified files:
/loncom lond
Log:
&get_institutional_id_rules() and &institutional_id_check() available to retrieve information about ID rules from localenroll.pm, and to check a proposed ID against ID rules for the domain, for which checking is enabled.
- also when applying roles filter in &dump_domainroles_handler() use \Q\E to protect each role extracted from nohist_domainroles.db
Index: loncom/lond
diff -u loncom/lond:1.388 loncom/lond:1.389
--- loncom/lond:1.388 Sat Oct 13 13:07:56 2007
+++ loncom/lond Fri Nov 9 22:38:28 2007
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.388 2007/10/13 17:07:56 raeburn Exp $
+# $Id: lond,v 1.389 2007/11/10 03:38:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.388 $'; #' stupid emacs
+my $VERSION='$Revision: 1.389 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4057,7 +4057,7 @@
}
}
unless (@roles < 1) {
- unless (grep/^$trole$/,@roles) {
+ unless (grep/^\Q$trole\E$/,@roles) {
$match = 0;
}
}
@@ -4666,6 +4666,40 @@
}
®ister_handler("instuserrules",\&get_institutional_user_rules,0,1,0);
+sub get_institutional_id_rules {
+ my ($cmd, $tail, $client) = @_;
+ my $userinput = "$cmd:$tail";
+ my $dom = &unescape($tail);
+ my (%rules_hash,@rules_order);
+ my $outcome;
+ eval {
+ local($SIG{__DIE__})='DEFAULT';
+ $outcome = &localenroll::id_rules($dom,\%rules_hash,\@rules_order);
+ };
+ if (!$@) {
+ if ($outcome eq 'ok') {
+ my $result;
+ foreach my $key (keys(%rules_hash)) {
+ $result .= &escape($key).'='.&Apache::lonnet::freeze_escape($rules_hash{$key}).'&';
+ }
+ $result =~ s/\&$//;
+ $result .= ':';
+ if (@rules_order > 0) {
+ foreach my $item (@rules_order) {
+ $result .= &escape($item).'&';
+ }
+ }
+ $result =~ s/\&$//;
+ &Reply($client,\$result,$userinput);
+ } else {
+ &Reply($client,"error\n", $userinput);
+ }
+ } else {
+ &Failure($client,"unknown_cmd\n",$userinput);
+ }
+}
+®ister_handler("instidrules",\&get_institutional_id_rules,0,1,0);
+
sub institutional_username_check {
my ($cmd, $tail, $client) = @_;
@@ -4696,6 +4730,34 @@
}
®ister_handler("instrulecheck",\&institutional_username_check,0,1,0);
+sub institutional_id_check {
+ my ($cmd, $tail, $client) = @_;
+ my $userinput = "$cmd:$tail";
+ my %rulecheck;
+ my $outcome;
+ my ($udom,$id,@rules) = split(/:/,$tail);
+ $udom = &unescape($udom);
+ $id = &unescape($id);
+ @rules = map {&unescape($_);} (@rules);
+ eval {
+ local($SIG{__DIE__})='DEFAULT';
+ $outcome = &localenroll::id_check($udom,$id,\@rules,\%rulecheck);
+ };
+ if (!$@) {
+ if ($outcome eq 'ok') {
+ my $result='';
+ foreach my $key (keys(%rulecheck)) {
+ $result.=&escape($key).'='.&Apache::lonnet::freeze_escape($rulecheck{$key}).'&';
+ }
+ &Reply($client,\$result,$userinput);
+ } else {
+ &Reply($client,"error\n", $userinput);
+ }
+ } else {
+ &Failure($client,"unknown_cmd\n",$userinput);
+ }
+}
+®ister_handler("instidrulecheck",\&institutional_id_check,0,1,0);
# Get domain specific conditions for import of student photographs to a course
#