---
name: "krb5_set_password"
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_set_password"
---

# krb5\_set\_password(3)

change password functions

## NAME

**krb5\_change\_password**, **krb5\_set\_password**, **krb5\_set\_password\_using\_ccache**, **krb5\_passwd\_result\_to\_string** – change password functions

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

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

*krb5\_error\_code*\

**krb5\_change\_password**(*krb5\_context context*, *krb5\_creds \*creds*, *char \*newpw*, *int \*result\_code*, *krb5\_data \*result\_code\_string*, *krb5\_data \*result\_string*);

*krb5\_error\_code*\

**krb5\_set\_password**(*krb5\_context context*, *krb5\_creds \*creds*, *char \*newpw*, *krb5\_principal targprinc*, *int \*result\_code*, *krb5\_data \*result\_code\_string*, *krb5\_data \*result\_string*);

*krb5\_error\_code*\

**krb5\_set\_password\_using\_ccache**(*krb5\_context context*, *krb5\_ccache ccache*, *char \*newpw*, *krb5\_principal targprinc*, *int \*result\_code*, *krb5\_data \*result\_code\_string*, *krb5\_data \*result\_string*);

*const char \**\

**krb5\_passwd\_result\_to\_string**(*krb5\_context context*, *int result*);

## DESCRIPTION

These functions change the password for a given principal.

**krb5\_set\_password**() and **krb5\_set\_password\_using\_ccache**() are the newer of the three functions, and use a newer version of the protocol (and also fall back to the older set-password protocol if the newer protocol doesn't work).

**krb5\_change\_password**() sets the password *newpasswd* for the client principal in *creds*. The server principal of creds must be kadmin/changepw.

**krb5\_set\_password**() and **krb5\_set\_password\_using\_ccache**() change the password for the principal *targprinc*.

**krb5\_set\_password**() requires that the credential for kadmin/changepw@REALM is in *creds*. If the user caller isn't an administrator, this credential needs to be an initial credential, see [krb5\_get\_init\_creds(3)](/krb5_get_init_creds/3.md) how to get such credentials.

**krb5\_set\_password\_using\_ccache**() will get the credential from *ccache*.

If *targprinc* is NULL, **krb5\_set\_password\_using\_ccache**() uses the the default principal in *ccache* and **krb5\_set\_password**() uses the global the default principal.

All three functions return an error in *result\_code* and maybe an error string to print in *result\_string*.

**krb5\_passwd\_result\_to\_string**() returns an human readable string describing the error code in *result\_code* from the **krb5\_set\_password**() functions.

## SEE ALSO

[krb5\_ccache(3)](/krb5_ccache/3.md), [krb5\_init\_context(3)](/krb5_init_context/3.md)
