The qkrb_count_kt_entries() function allows you to
obtain the total count of entries in a keytab file or count the number
of keytab entries there are for a particular principal.
Authorities and Locks
Object
Authority Required
All directories in the path to the keytab file
*X
Keytab file
*R
Parameters
keytab (Input)
The name of the keytab file that will be searched.
NULL
The default keytab file will be searched.
principal (Input)
The principal name of the keytab entries being counted.
NULL
Include keytab entries with any principal
name in the count.
Note: If the realm name is not included in the
specified principal name, the default realm will be appended to the name.
version (Input)
The version number of the keytab entries being counted.
0
Include keytab entries with any version
in the count.
count (Output)
The total number of entries in the keytab file that meet the search
criteria specified in the principal name and version number parameters.
Error Messages
Message ID
Error Message Text
CPE3C3C E
Value for parameter & not valid.
CPE4ABB E
Network Authentication Service failed with return code &1.
Example
The following example will count the number of keytab entries in
the default keytab file.
#include <krb5.h>
#include <string.h.h>
#include <stdio.h.h>
int main(int argc, char *argv[])
{
/* Count the number of keytab entries in the default keytab */
/* file for the specified principal name and version number. */
/* This program accepts 2 parameters: */
/* 1: Pointer to keytab entry's principal name */
/* 2: Keytab entry's version number */
char *principal;
krb5_kvno version;
int return_count;
/* Copy the address of the principal name and the value of the */
/* version number to local variables. */
principal = argv[1];
version = atoi(argv[2]);
/* Clear the count. */
return_count = 0;
/* Count the keytab entries. */
/* NOTE: When the first parameter, keytab, is set to NULL the */
/* default keytab file is used. The default keytab file */
/* is commonly: */
/* /QIBM/UserData/OS400/NetworkAuthentication/keytab/krb5.keytab */
qkrb_count_kt_entries(NULL, principal, version, &return_count);
/* Print the count. */
printf ("%s Principal: \n", principal);
printf ("%i Version number: \n", (int)version);
printf ("%i Number of keytab entries: \n", return_count);
return;
}