summaryrefslogtreecommitdiffstats
path: root/doc/doxyout/krb5/html/krb5_ccache_intro.html
blob: a0992dc66a942bd1d515649dac310706ab668aff (plain)
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
71
72
73
74
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>HeimdalKerberos5library: The credential cache functions</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<p>
<a href="http://www.h5l.org/"><img src="http://www.h5l.org/keyhole-heimdal.png" alt="keyhole logo"/></a>
</p>
<!-- end of header marker -->
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1><a class="anchor" name="krb5_ccache_intro">The credential cache functions </a></h1><h2><a class="anchor" name="section_krb5_ccache">
Kerberos credential caches</a></h2>
krb5_ccache structure holds a Kerberos credential cache.<p>
Heimdal support the follow types of credential caches:<p>
<ul>
<li>SCC Store the credential in a database</li><li>FILE Store the credential in memory</li><li>MEMORY Store the credential in memory</li><li>API A credential cache server based solution for Mac OS X</li><li>KCM A credential cache server based solution for all platforms</li></ul>
<h3><a class="anchor" name="Example">
Example</a></h3>
This is a minimalistic version of klist: <div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;krb5.h&gt;</span>

<span class="keywordtype">int</span>
main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
    krb5_context context;
    krb5_cc_cursor cursor;
    krb5_error_code ret;
    krb5_ccache id;
    krb5_creds creds;

    <span class="keywordflow">if</span> (<a class="code" href="group__krb5.html#gbd94206e186c58a093975424a4a567a8">krb5_init_context</a> (&amp;context) != 0)
        errx(1, <span class="stringliteral">"krb5_context"</span>);

    ret = <a class="code" href="group__krb5__ccache.html#gd7d54822ef022f3e27f7f0f457d9c751">krb5_cc_default</a> (context, &amp;<span class="keywordtype">id</span>);
    <span class="keywordflow">if</span> (ret)
        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_default"</span>);

    ret = <a class="code" href="group__krb5__ccache.html#gcbf766cea6b49dd64b76628c7708b979">krb5_cc_start_seq_get</a>(context, <span class="keywordtype">id</span>, &amp;cursor);
    <span class="keywordflow">if</span> (ret)
        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_start_seq_get"</span>);

    <span class="keywordflow">while</span>((ret = <a class="code" href="group__krb5__ccache.html#gd9cd0ebcc7bdf3ca2b0ed166ea2f8df6">krb5_cc_next_cred</a>(context, <span class="keywordtype">id</span>, &amp;cursor, &amp;creds)) == 0){
        <span class="keywordtype">char</span> *principal;

        <a class="code" href="group__krb5__principal.html#gac881051ed59fe0dcd08cee62280b332">krb5_unparse_name</a>(context, creds.server, &amp;principal);
        printf(<span class="stringliteral">"principal: %s\\n"</span>, principal);
        free(principal);
        <a class="code" href="group__krb5.html#gd89c4c7b633646c39e4a34a7230c94e1">krb5_free_cred_contents</a> (context, &amp;creds);
    }
    ret = <a class="code" href="group__krb5__ccache.html#g024ce036ebf277f918354d4681bd0550">krb5_cc_end_seq_get</a>(context, <span class="keywordtype">id</span>, &amp;cursor);
    <span class="keywordflow">if</span> (ret)
        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_end_seq_get"</span>);

    <a class="code" href="group__krb5__ccache.html#gebc0dd2a77529c05fb49e27235da7017">krb5_cc_close</a>(context, <span class="keywordtype">id</span>);

    <a class="code" href="group__krb5.html#ge51d83f5d5f589883f1cd10887892777">krb5_free_context</a>(context);
    <span class="keywordflow">return</span> 0;
}
</pre></div> </div>
<hr size="1"><address style="text-align: right;"><small>
Generated on Fri Sep 30 15:26:18 2011 for HeimdalKerberos5library by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>
OpenPOWER on IntegriCloud