我正在尝试使用 MIT Kerberos 实现(使用 k4w-4.0.1 中的 krb5_32.dll 和相关的头文件)来获取 TGT 和服务票证。
我已经加载了 krb5_init_context 函数,根据头文件 google 和 SO,它只需要 1 个参数(krb5_context 结构)并填充它。
#include "stdafx.h"
#include "windows.h"
#include "krb5.h"
typedef int krb5_int32;
typedef krb5_int32 krb5_error_code;
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE kerberos = LoadLibrary(L"krb5_32.dll");
HANDLE krb5_init_context = NULL;
if(kerberos == NULL)
{
printf("Failed to load library!\n");
printf("%lu", GetLastError());
return -1;
}
else
{
printf("Library krb5_32.dll loaded successfully!\n");
}
if((krb5_init_context = GetProcAddress(kerberos, "krb5_init_context")) == NULL)
{
printf("GetProcAddress for krb5_init_context failed!\n");
return -1;
}
else
{
printf("Function krb5_init_context loaded successfully!\n");
}
krb5_context context = NULL;
krb5_ccache cache = NULL;
krb5_principal client_princ = NULL;
char* name = NULL;
krb5_keytab keytab = 0;
krb5_creds creds;
krb5_get_init_creds_opt *options = NULL;
krb5_error_code error_code = 0; //error_status_ok;
error_code = (*krb5_init_context)(&context);
printf("Error Code: " + error_code);
while(true);
return 0;
}