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>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.9.1 --> 12<script type="text/javascript" src="menudata.js"></script> 13<script type="text/javascript" src="menu.js"></script> 14<script type="text/javascript"> 15/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ 16$(function() { 17 initMenu('',false,false,'search.php','Search'); 18}); 19/* @license-end */</script> 20<div id="main-nav"></div> 21</div><!-- top --> 22<div class="PageDoc"><div class="header"> 23 <div class="headertitle"> 24<div class="title">The credential cache functions </div> </div> 25</div><!--header--> 26<div class="contents"> 27<div class="textblock"><h1><a class="anchor" id="section_krb5_ccache"></a> 28Kerberos credential caches</h1> 29<p>krb5_ccache structure holds a Kerberos credential cache.</p> 30<p>Heimdal support the follow types of credential caches:</p> 31<ul> 32<li>SCC Store the credential in a database</li> 33<li>FILE Store the credential in memory</li> 34<li>MEMORY Store the credential in memory</li> 35<li>API A credential cache server based solution for Mac OS X</li> 36<li>KCM A credential cache server based solution for all platforms</li> 37</ul> 38<h2><a class="anchor" id="Example"></a> 39Example</h2> 40<p>This is a minimalistic version of klist: </p><div class="fragment"><div class="line"><span class="preprocessor">#include <krb5.h></span></div> 41<div class="line"> </div> 42<div class="line"><span class="keywordtype">int</span></div> 43<div class="line">main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div> 44<div class="line">{</div> 45<div class="line"> krb5_context context;</div> 46<div class="line"> krb5_cc_cursor cursor;</div> 47<div class="line"> krb5_error_code ret;</div> 48<div class="line"> krb5_ccache id;</div> 49<div class="line"> krb5_creds creds;</div> 50<div class="line"> </div> 51<div class="line"> <span class="keywordflow">if</span> (<a class="code" href="group__krb5.html#gabd94206e186c58a093975424a4a567a8">krb5_init_context</a> (&context) != 0)</div> 52<div class="line"> errx(1, <span class="stringliteral">"krb5_context"</span>);</div> 53<div class="line"> </div> 54<div class="line"> ret = <a class="code" href="group__krb5__ccache.html#gad7d54822ef022f3e27f7f0f457d9c751">krb5_cc_default</a> (context, &<span class="keywordtype">id</span>);</div> 55<div class="line"> <span class="keywordflow">if</span> (ret)</div> 56<div class="line"> <a class="code" href="group__krb5__error.html#gad75c268bcf26225ee8d4a39c178131a1">krb5_err</a>(context, 1, ret, <span class="stringliteral">"krb5_cc_default"</span>);</div> 57<div class="line"> </div> 58<div class="line"> ret = <a class="code" href="group__krb5__ccache.html#gacbf766cea6b49dd64b76628c7708b979">krb5_cc_start_seq_get</a>(context, <span class="keywordtype">id</span>, &cursor);</div> 59<div class="line"> <span class="keywordflow">if</span> (ret)</div> 60<div class="line"> <a class="code" href="group__krb5__error.html#gad75c268bcf26225ee8d4a39c178131a1">krb5_err</a>(context, 1, ret, <span class="stringliteral">"krb5_cc_start_seq_get"</span>);</div> 61<div class="line"> </div> 62<div class="line"> <span class="keywordflow">while</span>((ret = <a class="code" href="group__krb5__ccache.html#gad9cd0ebcc7bdf3ca2b0ed166ea2f8df6">krb5_cc_next_cred</a>(context, <span class="keywordtype">id</span>, &cursor, &creds)) == 0){</div> 63<div class="line"> <span class="keywordtype">char</span> *principal;</div> 64<div class="line"> </div> 65<div class="line"> <a class="code" href="group__krb5__principal.html#gaac881051ed59fe0dcd08cee62280b332">krb5_unparse_name</a>(context, creds.server, &principal);</div> 66<div class="line"> printf(<span class="stringliteral">"principal: %s\\n"</span>, principal);</div> 67<div class="line"> free(principal);</div> 68<div class="line"> <a class="code" href="group__krb5.html#gad89c4c7b633646c39e4a34a7230c94e1">krb5_free_cred_contents</a> (context, &creds);</div> 69<div class="line"> }</div> 70<div class="line"> ret = <a class="code" href="group__krb5__ccache.html#ga024ce036ebf277f918354d4681bd0550">krb5_cc_end_seq_get</a>(context, <span class="keywordtype">id</span>, &cursor);</div> 71<div class="line"> <span class="keywordflow">if</span> (ret)</div> 72<div class="line"> <a class="code" href="group__krb5__error.html#gad75c268bcf26225ee8d4a39c178131a1">krb5_err</a>(context, 1, ret, <span class="stringliteral">"krb5_cc_end_seq_get"</span>);</div> 73<div class="line"> </div> 74<div class="line"> <a class="code" href="group__krb5__ccache.html#gaebc0dd2a77529c05fb49e27235da7017">krb5_cc_close</a>(context, <span class="keywordtype">id</span>);</div> 75<div class="line"> </div> 76<div class="line"> <a class="code" href="group__krb5.html#gae51d83f5d5f589883f1cd10887892777">krb5_free_context</a>(context);</div> 77<div class="line"> <span class="keywordflow">return</span> 0;</div> 78<div class="line">}</div> 79<div class="ttc" id="agroup__krb5__ccache_html_ga024ce036ebf277f918354d4681bd0550"><div class="ttname"><a href="group__krb5__ccache.html#ga024ce036ebf277f918354d4681bd0550">krb5_cc_end_seq_get</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_cc_end_seq_get(krb5_context context, const krb5_ccache id, krb5_cc_cursor *cursor)</div><div class="ttdef"><b>Definition:</b> cache.c:875</div></div> 80<div class="ttc" id="agroup__krb5__ccache_html_gacbf766cea6b49dd64b76628c7708b979"><div class="ttname"><a href="group__krb5__ccache.html#gacbf766cea6b49dd64b76628c7708b979">krb5_cc_start_seq_get</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_cc_start_seq_get(krb5_context context, const krb5_ccache id, krb5_cc_cursor *cursor)</div><div class="ttdef"><b>Definition:</b> cache.c:841</div></div> 81<div class="ttc" id="agroup__krb5__ccache_html_gad7d54822ef022f3e27f7f0f457d9c751"><div class="ttname"><a href="group__krb5__ccache.html#gad7d54822ef022f3e27f7f0f457d9c751">krb5_cc_default</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_cc_default(krb5_context context, krb5_ccache *id)</div><div class="ttdef"><b>Definition:</b> cache.c:649</div></div> 82<div class="ttc" id="agroup__krb5__ccache_html_gad9cd0ebcc7bdf3ca2b0ed166ea2f8df6"><div class="ttname"><a href="group__krb5__ccache.html#gad9cd0ebcc7bdf3ca2b0ed166ea2f8df6">krb5_cc_next_cred</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_cc_next_cred(krb5_context context, const krb5_ccache id, krb5_cc_cursor *cursor, krb5_creds *creds)</div><div class="ttdef"><b>Definition:</b> cache.c:859</div></div> 83<div class="ttc" id="agroup__krb5__ccache_html_gaebc0dd2a77529c05fb49e27235da7017"><div class="ttname"><a href="group__krb5__ccache.html#gaebc0dd2a77529c05fb49e27235da7017">krb5_cc_close</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_cc_close(krb5_context context, krb5_ccache id)</div><div class="ttdef"><b>Definition:</b> cache.c:712</div></div> 84<div class="ttc" id="agroup__krb5__error_html_gad75c268bcf26225ee8d4a39c178131a1"><div class="ttname"><a href="group__krb5__error.html#gad75c268bcf26225ee8d4a39c178131a1">krb5_err</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_err(krb5_context context, int eval, krb5_error_code code, const char *fmt,...) __attribute__((__noreturn__</div></div> 85<div class="ttc" id="agroup__krb5__principal_html_gaac881051ed59fe0dcd08cee62280b332"><div class="ttname"><a href="group__krb5__principal.html#gaac881051ed59fe0dcd08cee62280b332">krb5_unparse_name</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_unparse_name(krb5_context context, krb5_const_principal principal, char **name)</div><div class="ttdef"><b>Definition:</b> principal.c:608</div></div> 86<div class="ttc" id="agroup__krb5_html_gabd94206e186c58a093975424a4a567a8"><div class="ttname"><a href="group__krb5.html#gabd94206e186c58a093975424a4a567a8">krb5_init_context</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_init_context(krb5_context *context)</div><div class="ttdef"><b>Definition:</b> context.c:417</div></div> 87<div class="ttc" id="agroup__krb5_html_gad89c4c7b633646c39e4a34a7230c94e1"><div class="ttname"><a href="group__krb5.html#gad89c4c7b633646c39e4a34a7230c94e1">krb5_free_cred_contents</a></div><div class="ttdeci">KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_free_cred_contents(krb5_context context, krb5_creds *c)</div><div class="ttdef"><b>Definition:</b> creds.c:49</div></div> 88<div class="ttc" id="agroup__krb5_html_gae51d83f5d5f589883f1cd10887892777"><div class="ttname"><a href="group__krb5.html#gae51d83f5d5f589883f1cd10887892777">krb5_free_context</a></div><div class="ttdeci">KRB5_LIB_FUNCTION void KRB5_LIB_CALL krb5_free_context(krb5_context context)</div><div class="ttdef"><b>Definition:</b> context.c:615</div></div> 89</div><!-- fragment --> </div></div><!-- contents --> 90</div><!-- PageDoc --> 91<hr size="1"><address style="text-align: right;"><small> 92Generated on Tue Nov 15 2022 14:04:26 for Heimdal Kerberos 5 library by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.9.1</small></address> 93</body> 94</html> 95