KRB5_GET_CREDENTIALS(3)  BSD Library Functions Manual  KRB5_GET_CREDENTIALS(3)

[1mNAME[0m
     [1mkrb5_get_credentials[22m, [1mkrb5_get_credentials_with_flags[22m, [1mkrb5_get_kdc_cred[22m,
     [1mkrb5_get_renewed_creds [22m-- get credentials from the KDC using krbtgt

[1mLIBRARY[0m
     Kerberos 5 Library (libkrb5, -lkrb5)

[1mSYNOPSIS[0m
     [1m#include <krb5.h>[0m

     [4mkrb5_error_code[0m
     [1mkrb5_get_credentials[22m([4mkrb5_context[24m [4mcontext[24m, [4mkrb5_flags[24m [4moptions[24m,
         [4mkrb5_ccache[24m [4mccache[24m, [4mkrb5_creds[24m [4m*in_creds[24m, [4mkrb5_creds[24m [4m**out_creds[24m);

     [4mkrb5_error_code[0m
     [1mkrb5_get_credentials_with_flags[22m([4mkrb5_context[24m [4mcontext[24m, [4mkrb5_flags[24m [4moptions[24m,
         [4mkrb5_kdc_flags[24m [4mflags[24m, [4mkrb5_ccache[24m [4mccache[24m, [4mkrb5_creds[24m [4m*in_creds[24m,
         [4mkrb5_creds[24m [4m**out_creds[24m);

     [4mkrb5_error_code[0m
     [1mkrb5_get_kdc_cred[22m([4mkrb5_context[24m [4mcontext[24m, [4mkrb5_ccache[24m [4mid[24m,
         [4mkrb5_kdc_flags[24m [4mflags[24m, [4mkrb5_addresses[24m [4m*addresses[24m,
         [4mTicket[24m [4m*second_ticket[24m, [4mkrb5_creds[24m [4m*in_creds[24m, [4mkrb5_creds[24m [4m**out_creds[24m);

     [4mkrb5_error_code[0m
     [1mkrb5_get_renewed_creds[22m([4mkrb5_context[24m [4mcontext[24m, [4mkrb5_creds[24m [4m*creds[24m,
         [4mkrb5_const_principal[24m [4mclient[24m, [4mkrb5_ccache[24m [4mccache[24m,
         [4mconst[24m [4mchar[24m [4m*in_tkt_service[24m);

[1mDESCRIPTION[0m
     [1mkrb5_get_credentials_with_flags[22m() get credentials specified by
     [4min_creds->server[24m and [4min_creds->client[24m (the rest of the [4min_creds[24m structure
     is ignored) by first looking in the [4mccache[24m and if doesn't exists or is
     expired, fetch the credential from the KDC using the krbtgt in [4mccache[24m.
     The credential is returned in [4mout_creds[24m and should be freed using the
     function [1mkrb5_free_creds[22m().

     Valid flags to pass into [4moptions[24m argument are:

     KRB5_GC_CACHED      Only check the [4mccache[24m, don't got out on network to
                         fetch credential.
     KRB5_GC_USER_USER   Request a user to user ticket.  This option doesn't
                         store the resulting user to user credential in the
                         [4mccache[24m.
     KRB5_GC_EXPIRED_OK  returns the credential even if it is expired, default
                         behavior is trying to refetch the credential from the
                         KDC.

     [4mFlags[24m are KDCOptions, note the caller must fill in the bit-field and not
     use the integer associated structure.

     [1mkrb5_get_credentials[22m() works the same way as
     [1mkrb5_get_credentials_with_flags[22m() except that the [4mflags[24m field is missing.

     [1mkrb5_get_kdc_cred[22m() does the same as the functions above, but the caller
     must fill in all the information andits closer to the wire protocol.

     [1mkrb5_get_renewed_creds[22m() renews a credential given by [4min_tkt_service[24m (if
     NULL the default krbtgt) using the credential cache [4mccache[24m.  The result
     is stored in [4mcreds[24m and should be freed using [4mkrb5_free_creds[24m.

[1mEXAMPLES[0m
     Here is a example function that get a credential from a credential cache
     [4mid[24m or the KDC and returns it to the caller.

     #include <krb5.h>

     int
     getcred(krb5_context context, krb5_ccache id, krb5_creds **creds)
     {
         krb5_error_code ret;
         krb5_creds in;

         ret = krb5_parse_name(context, "client@EXAMPLE.COM",
                               &in.client);
         if (ret)
             krb5_err(context, 1, ret, "krb5_parse_name");

         ret = krb5_parse_name(context, "host/server.example.com@EXAMPLE.COM",
                               &in.server);
         if (ret)
             krb5_err(context, 1, ret, "krb5_parse_name");

         ret = krb5_get_credentials(context, 0, id, &in, creds);
         if (ret)
             krb5_err(context, 1, ret, "krb5_get_credentials");

         return 0;
     }

[1mSEE ALSO[0m
     krb5(3), krb5_get_forwarded_creds(3), krb5.conf(5)

HEIMDAL                          July 26, 2004                         HEIMDAL
