[LON-CAPA-cvs] cvs: modules /matthew krb4_test.pl

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 29 Nov 2004 15:12:03 -0000


matthew		Mon Nov 29 10:12:03 2004 EDT

  Added files:                 
    /modules/matthew	krb4_test.pl 
  Log:
  Simple script to test krb4 authentication, specifically multiple
  authentication attempts.
  
  

Index: modules/matthew/krb4_test.pl
+++ modules/matthew/krb4_test.pl
#!/usr/bin/perl -w
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#


=pod

=head1 NAME

krb4_test.pl

=head1 SYNOPSIS

Script to test Kerberos IV authentication

=head1 USAGE

You will need to modify this script to contain the proper $uname, 
$contentpwd, and $upass

For Michigan State University kerberos authentication is configured 
with /etc/krb.conf beginning with:

  MSU.EDU
  MSU.EDU         afsdb0.cl.msu.edu

=cut

use strict;
use Authen::Krb4;

my $uname = 'hallmat3';        # username to use 
my $contentpwd = 'MSU.EDU';    # kerberos realm or domain
my $upass = '';                # Enter a password here or, at least in some
                               # cases you will be prompted for the password
chomp($upass);

my $phost = &Authen::Krb4::get_phost($contentpwd);
print "phost = ".$phost."\n";

my $krb4_error = &Authen::Krb4::get_pw_in_tkt($uname,"",$contentpwd,'krbtgt',
                                              $contentpwd,1,$upass);

for (my $i=1;$i<=4;$i++) {
    $krb4_error = &Authen::Krb4::get_pw_in_tkt($uname,"",$contentpwd,'krbtgt',
                                               $contentpwd,1,$upass);
    print "$i: krb4 error status = ".
        &Authen::Krb4::get_err_txt($Authen::Krb4::error)."\n";
}