1 2#include <Kerberos/KerberosLogin.h> 3#include <stdio.h> 4#include <err.h> 5 6int 7main(int argc, char **argv) 8{ 9 int error; 10 char *outName = NULL; 11 char *name, *instance, *realm; 12 KLBoolean foundTickets = 0; 13 char *cacheName; 14 KLPrincipal principal; 15 uint32_t version; 16 17 error = KLCacheHasValidTickets(NULL, kerberosVersion_V5, 18 &foundTickets, &principal, &cacheName); 19 if (error) 20 errx(1, "no valid ticket"); 21 22 error = KLGetTripletFromPrincipal (principal, &name, &instance, &realm); 23 KLDisposePrincipal (principal); 24 if (error) 25 errx(1, "failed to parse principal"); 26 27 printf("name: %s instance: %s realm: %s\n", name, instance, realm); 28 29 KLDisposeString (name); 30 KLDisposeString (instance); 31 KLDisposeString (realm); 32 33 return 0; 34} 35