---
name: "krb5_get_creds_opt_set_options"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "7.8.git20221117.28daf24+dfsg-9+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/krb5_get_creds_opt_set_options"
---

# krb5\_get\_creds\_opt\_set\_options(3)

get credentials from the KDC

## NAME

**krb5\_get\_creds**, **krb5\_get\_creds\_opt\_add\_options**, **krb5\_get\_creds\_opt\_alloc**, **krb5\_get\_creds\_opt\_free**, **krb5\_get\_creds\_opt\_set\_enctype**, **krb5\_get\_creds\_opt\_set\_impersonate**, **krb5\_get\_creds\_opt\_set\_options**, **krb5\_get\_creds\_opt\_set\_ticket** – get credentials from the KDC

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

**#include \<krb5.h\>**

*krb5\_error\_code*\

**krb5\_get\_creds**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *krb5\_ccache ccache*, *krb5\_const\_principal inprinc*, *krb5\_creds \*\*out\_creds*);

*void*\

**krb5\_get\_creds\_opt\_add\_options**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *krb5\_flags options*);

*krb5\_error\_code*\

**krb5\_get\_creds\_opt\_alloc**(*krb5\_context context*, *krb5\_get\_creds\_opt \*opt*);

*void*\

**krb5\_get\_creds\_opt\_free**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*);

*void*\

**krb5\_get\_creds\_opt\_set\_enctype**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *krb5\_enctype enctype*);

*krb5\_error\_code*\

**krb5\_get\_creds\_opt\_set\_impersonate**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *krb5\_const\_principal self*);

*void*\

**krb5\_get\_creds\_opt\_set\_options**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *krb5\_flags options*);

*krb5\_error\_code*\

**krb5\_get\_creds\_opt\_set\_ticket**(*krb5\_context context*, *krb5\_get\_creds\_opt opt*, *const Ticket \*ticket*);

## DESCRIPTION

**krb5\_get\_creds**() fetches credentials specified by *opt* by first looking in the *ccache*, and then it doesn't exists, fetch the credential from the KDC using the krbtgts in *ccache*. The credential is returned in *out\_creds* and should be freed using the function **krb5\_free\_creds**().

The structure krb5\_get\_creds\_opt controls the behavior of **krb5\_get\_creds**(). The structure is opaque to consumers that can set the content of the structure with accessors functions. All accessor functions make copies of the data that is passed into accessor functions, so external consumers free the memory before calling **krb5\_get\_creds**().

The structure krb5\_get\_creds\_opt is allocated with **krb5\_get\_creds\_opt\_alloc**() and freed with **krb5\_get\_creds\_opt\_free**(). The free function also frees the content of the structure set by the accessor functions.

**krb5\_get\_creds\_opt\_add\_options**() and **krb5\_get\_creds\_opt\_set\_options**() adds and sets options to the krb5\_get\_creds\_opt structure . The possible options to set are

- KRB5\_GC\_CACHED

  Only check the *ccache*, don't got out on network to fetch credential.

- KRB5\_GC\_USER\_USER

  request a user to user ticket. This options doesn't store the resulting user to user credential in the *ccache*.

- KRB5\_GC\_EXPIRED\_OK

  returns the credential even if it is expired, default behavior is trying to refetch the credential from the KDC.

- KRB5\_GC\_NO\_STORE

  Do not store the resulting credentials in the *ccache*.

**krb5\_get\_creds\_opt\_set\_enctype**() sets the preferred encryption type of the application. Don't set this unless you have to since if there is no match in the KDC, the function call will fail.

**krb5\_get\_creds\_opt\_set\_impersonate**() sets the principal to impersonate., Returns a ticket that have the impersonation principal as a client and the requestor as the service. Note that the requested principal have to be the same as the client principal in the krbtgt.

**krb5\_get\_creds\_opt\_set\_ticket**() sets the extra ticket used in user-to-user or contrained delegation use case.

## SEE ALSO

[krb5(3)](/krb5/3.md), [krb5\_get\_credentials(3)](/krb5_get_credentials/3.md), [krb5.conf(5)](/krb5.conf/5.md)
