1#!/usr/local/bin/perl
2
3# sample_client
4# sends authentication info to a server via sendauth
5
6use blib; # remove if not in module build directory
7use IO::Socket;
8use Authen::Krb5 (KRB5_NT_SRV_HST);
9
10# replace with your own stuff
11$SERVICE = "sample";
12$SERVER = "server.domain.edu";
13
14Authen::Krb5::init_context();
15
16$ac = new Authen::Krb5::AuthContext;
17
18$s = new IO::Socket::INET(
19	PeerAddr => $SERVER,
20	PeerPort => 12345,
21	Proto => 'tcp'
22);
23defined $s or die $!;
24
25$cc = Authen::Krb5::cc_default();
26
27$clientp = Authen::Krb5::parse_name($ENV{'USER'});
28$serverp = Authen::Krb5::sname_to_principal($SERVER,$SERVICE,KRB5_NT_SRV_HST);
29if (Authen::Krb5::sendauth($ac,$s,"V1",$clientp,$serverp,
30	AP_OPTS_MUTUAL_REQUIRED,"test",undef,$cc)) {
31	print "Sent authentication info.\n";
32}
33else {
34	print "sendauth error: ",Authen::Krb5::error(),"\n";
35}
36
37close($s);
38
39Authen::Krb5::free_context();
40