xref: /freebsd/crypto/heimdal/doc/doxyout/krb5/html/krb5_ccache_intro.html (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>HeimdalKerberos5library: The credential cache functions</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<p>
8<a href="http://www.h5l.org/"><img src="http://www.h5l.org/keyhole-heimdal.png" alt="keyhole logo"/></a>
9</p>
10<!-- end of header marker -->
11<!-- Generated by Doxygen 1.5.6 -->
12<div class="navigation" id="top">
13  <div class="tabs">
14    <ul>
15      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
16      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
17      <li><a href="modules.html"><span>Modules</span></a></li>
18      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
19    </ul>
20  </div>
21</div>
22<div class="contents">
23<h1><a class="anchor" name="krb5_ccache_intro">The credential cache functions </a></h1><h2><a class="anchor" name="section_krb5_ccache">
24Kerberos credential caches</a></h2>
25krb5_ccache structure holds a Kerberos credential cache.<p>
26Heimdal support the follow types of credential caches:<p>
27<ul>
28<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>
29<h3><a class="anchor" name="Example">
30Example</a></h3>
31This is a minimalistic version of klist: <div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;krb5.h&gt;</span>
32
33<span class="keywordtype">int</span>
34main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
35{
36    krb5_context context;
37    krb5_cc_cursor cursor;
38    krb5_error_code ret;
39    krb5_ccache id;
40    krb5_creds creds;
41
42    <span class="keywordflow">if</span> (<a class="code" href="group__krb5.html#gbd94206e186c58a093975424a4a567a8">krb5_init_context</a> (&amp;context) != 0)
43        errx(1, <span class="stringliteral">"krb5_context"</span>);
44
45    ret = <a class="code" href="group__krb5__ccache.html#gd7d54822ef022f3e27f7f0f457d9c751">krb5_cc_default</a> (context, &amp;<span class="keywordtype">id</span>);
46    <span class="keywordflow">if</span> (ret)
47        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_default"</span>);
48
49    ret = <a class="code" href="group__krb5__ccache.html#gcbf766cea6b49dd64b76628c7708b979">krb5_cc_start_seq_get</a>(context, <span class="keywordtype">id</span>, &amp;cursor);
50    <span class="keywordflow">if</span> (ret)
51        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_start_seq_get"</span>);
52
53    <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){
54        <span class="keywordtype">char</span> *principal;
55
56        <a class="code" href="group__krb5__principal.html#gac881051ed59fe0dcd08cee62280b332">krb5_unparse_name</a>(context, creds.server, &amp;principal);
57        printf(<span class="stringliteral">"principal: %s\\n"</span>, principal);
58        free(principal);
59        <a class="code" href="group__krb5.html#gd89c4c7b633646c39e4a34a7230c94e1">krb5_free_cred_contents</a> (context, &amp;creds);
60    }
61    ret = <a class="code" href="group__krb5__ccache.html#g024ce036ebf277f918354d4681bd0550">krb5_cc_end_seq_get</a>(context, <span class="keywordtype">id</span>, &amp;cursor);
62    <span class="keywordflow">if</span> (ret)
63        krb5_err(context, 1, ret, <span class="stringliteral">"krb5_cc_end_seq_get"</span>);
64
65    <a class="code" href="group__krb5__ccache.html#gebc0dd2a77529c05fb49e27235da7017">krb5_cc_close</a>(context, <span class="keywordtype">id</span>);
66
67    <a class="code" href="group__krb5.html#ge51d83f5d5f589883f1cd10887892777">krb5_free_context</a>(context);
68    <span class="keywordflow">return</span> 0;
69}
70</pre></div> </div>
71<hr size="1"><address style="text-align: right;"><small>
72Generated on Wed Jan 11 14:07:47 2012 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>
73</body>
74</html>
75