#!/usr/local/bin/perl -w

use blib;
use AFS::KAS;
use AFS::KTC_PRINCIPAL;
use AFS::KTC_TOKEN;
use AFS::KTC_EKEY;
use AFS qw(raise_exception);

die "Usage: admin \n" if ($#ARGV != 0);

raise_exception(1);

my $princ = AFS::KTC_PRINCIPAL->new(shift);
my $key   = AFS::KTC_EKEY->ReadPassword($princ->name."'s Password:");
my $token = AFS::KTC_TOKEN->GetAdminToken($princ, $key, 300);

my $kas   = AFS::KAS->AuthServerConn($token, &AFS::KA_MAINTENANCE_SERVICE);

my $i = 0;
my $count = 1;

print "\n\nlistentry: \n";
while ($count) {
    printf("$count\t");
    my ($name, $inst) = $kas->listentry($i, $i, $count);
    printf("$name%s$inst\t\t$count\n", $inst ne '' ? '.' : '');
}

$i = 0;
$count = 1;

print "\n\nLAM_ListEntry: \n";
while ($count) {
    printf("$count\t");
    my ($name, $inst) = $kas->KAM_ListEntry($i, $i, $count);
    printf("$name%s$inst\t\t$count\n", $inst ne '' ? '.' : '');
}
