aboutsummaryrefslogtreecommitdiff
path: root/doc/doxyout/krb5/man/man3/krb5_ccache_intro.3
blob: 5ff2ad059ff9d6e7b9eaf8c26a4d484c55597cdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
.TH "krb5_ccache_intro" 3 "Fri Dec 8 2017" "Version 7.5.0" "HeimdalKerberos5library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
krb5_ccache_introThe credential cache functions 
 \- 
.SH "Kerberos credential caches"
.PP
krb5_ccache structure holds a Kerberos credential cache\&.
.PP
Heimdal support the follow types of credential caches:
.PP
.IP "\(bu" 2
SCC Store the credential in a database
.IP "\(bu" 2
FILE Store the credential in memory
.IP "\(bu" 2
MEMORY Store the credential in memory
.IP "\(bu" 2
API A credential cache server based solution for Mac OS X
.IP "\(bu" 2
KCM A credential cache server based solution for all platforms
.PP
.SS "Example"
This is a minimalistic version of klist: 
.PP
.nf
#include <krb5\&.h>

int
main (int argc, char **argv)
{
    krb5_context context;
    krb5_cc_cursor cursor;
    krb5_error_code ret;
    krb5_ccache id;
    krb5_creds creds;

    if (krb5_init_context (&context) != 0)
        errx(1, "krb5_context");

    ret = krb5_cc_default (context, &id);
    if (ret)
        krb5_err(context, 1, ret, "krb5_cc_default");

    ret = krb5_cc_start_seq_get(context, id, &cursor);
    if (ret)
        krb5_err(context, 1, ret, "krb5_cc_start_seq_get");

    while((ret = krb5_cc_next_cred(context, id, &cursor, &creds)) == 0){
        char *principal;

        krb5_unparse_name(context, creds\&.server, &principal);
        printf("principal: %s\\n", principal);
        free(principal);
        krb5_free_cred_contents (context, &creds);
    }
    ret = krb5_cc_end_seq_get(context, id, &cursor);
    if (ret)
        krb5_err(context, 1, ret, "krb5_cc_end_seq_get");

    krb5_cc_close(context, id);

    krb5_free_context(context);
    return 0;
}

.fi
.PP