// test using kerb95 library.
// 10/10, Naomaru Itoi.

#include <stdio.h>
#include <windows.h>
#include "kerberos.h"

#define CacheSize	15
#define StrLen 256
#define KerberosVersion 4

void main()
{
	INT rv;
	HANDLE hTktCc = (HANDLE)0;
	WCHAR *Username = L"itoi@UMICH.EDU";
	WCHAR *Password = L""; // password here
	WCHAR principal[StrLen], instance[StrLen], realm[StrLen];

	rv = KrbDoesTktCacheExist();
	//printf("cc exists ? %d\n", rv);
	if (!rv) {
		printf("Creating ticket cache ...\n");
		KrbCreateCache(15, hTktCc);
	}
	else {
		printf("Ticket cache already exists.\n");
	}
	
	KrbParseIdentity (Username, principal, instance, realm);
	wprintf(L"parse %s -> %s, %s, %s\n", Username, principal, instance, realm);

	if (!KrbRequestTGT (principal, instance, realm, Password, KerberosVersion)){
		wprintf(L"Can't get TGT for %s\n", principal);
	}
	else {
		wprintf(L"Got TGT!\n");
	}

}
