Error: Server not found in Kerberos database

Harvey Kravis harvey.kravis at sungardbsr.com
Mon Jul 14 14:38:49 EDT 2003


I am developing a C dll to get a TGT.  I am failing on the
krb5_get_in_tkt_with_password function with this error:

	Server not found in Kerberos database

Assume the following information (names changed to protect the innocent):

	realm:	REALM.COM
	instance:	REALM.COM (yes it's the same as the realm)
	user:		test1
	password:	test1

I can successfully get a TGT using kinit (or Leash32) for the user named
test1.

In my C code (I'm a C novice and getting help with this):

#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include "krb5.h"
#include "bsrkerberos.h"

LPSTR BSRKERBEROS_API krb_get_tgt ( LPSTR s_instance,
						LPSTR s_username,
						LPSTR s_password) 
{

	/* Variable declarations */

	krb5_context		context;
	krb5_principal		server;
	krb5_principal		client;
	krb5_creds			creds;
	krb5_kdc_rep		*kdc_rep;
	krb5_error_code		error_code;

	/* Get the context */

	if (error_code = krb5_init_context (&context))
	{
		com_err ("client",
			   error_code,
			   "krb5_init_context");
		return "1";
	}


	/* Populate the server structure with the principal */

	if (error_code = krb5_sname_to_principal (context,
								s_instance,
								s_username,
	
KRB5_NT_SRV_HST,
								&server))
	{
		com_err ("client",
			   error_code,
			   "krb5_sname_to_principal");
		return "2";
	}


	/* Populate the client structure with the user name */

	if (error_code = krb5_parse_name (context,
						    s_username,
						    &client))
	{
		com_err ("client",
			   error_code,
			   "krb5_parse_name");
		return "3";
	}

	/* Try getting the TGT */

	memset ((char *) &creds, 0, sizeof (creds));

	creds.client = client;
	creds.server = server;

	if (error_code = krb5_get_in_tkt_with_password (context,
									0
/*KRB5_DEFAULT_OPTIONS*/,
	
(krb5_address **) 0,
	
(krb5_enctype *) 0,
	
(krb5_preauthtype *) 0,
	
s_password,
	
(krb5_ccache) 0,
	
&creds,
	
&kdc_rep))
	{
		com_err ("client",
			   error_code,
			   "krb5_get_in_tkt_with_password");
		return "4";
	}
	
	return "";
}

The basis for this code came from the book, "Kerberos, A Network
Authentication System", by Brian Tung.

If anyone has an answer or bright idea, I'm all ears and will thank you
profusely.

Harvey Kravis
SunGard BSR Inc.



More information about the krbdev mailing list