# pam_setcred(3) - man - phpMan

[PAM_SETCRED(3)](https://www.chedong.com/phpMan.php/man/PAMSETCRED/3/markdown)                            Linux-PAM Manual                            [PAM_SETCRED(3)](https://www.chedong.com/phpMan.php/man/PAMSETCRED/3/markdown)



## NAME
       pam_setcred - establish / delete user credentials

## SYNOPSIS
       **#include** **<security/pam**___**appl.h>**

       **int** **pam**___**setcred(pam**___**handle**___**t** *****_pamh_**,** **int** _flags_**);**

## DESCRIPTION
       The **pam**___**setcred** function is used to establish, maintain and delete the credentials of a user.
       It should be called to set the credentials after a user has been authenticated and before a
       session is opened for the user (with **pam**___**open**___**[session**(3)](https://www.chedong.com/phpMan.php/man/session/3/markdown)). The credentials should be deleted
       after the session has been closed (with **pam**___**close**___**[session**(3)](https://www.chedong.com/phpMan.php/man/session/3/markdown)).

       A credential is something that the user possesses. It is some property, such as a _Kerberos_
       ticket, or a supplementary group membership that make up the uniqueness of a given user. On a
       Linux system the user's _UID_ and _GID_'s are credentials too. However, it has been decided that
       these properties (along with the default supplementary groups of which the user is a member)
       are credentials that should be set directly by the application and not by PAM. Such
       credentials should be established, by the application, prior to a call to this function. For
       example, [**initgroups**(2)](https://www.chedong.com/phpMan.php/man/initgroups/2/markdown) (or equivalent) should have been performed.

       Valid _flags_, any one of which, may be logically OR'd with **PAM**___**SILENT**, are:

       PAM_ESTABLISH_CRED
           Initialize the credentials for the user.

       PAM_DELETE_CRED
           Delete the user's credentials.

       PAM_REINITIALIZE_CRED
           Fully reinitialize the user's credentials.

       PAM_REFRESH_CRED
           Extend the lifetime of the existing credentials.

## RETURN VALUES
       PAM_BUF_ERR
           Memory buffer error.

       PAM_CRED_ERR
           Failed to set user credentials.

       PAM_CRED_EXPIRED
           User credentials are expired.

       PAM_CRED_UNAVAIL
           Failed to retrieve user credentials.

       PAM_SUCCESS
           Data was successful stored.

       PAM_SYSTEM_ERR
           A NULL pointer was submitted as PAM handle, the function was called by a module or
           another system error occurred.

       PAM_USER_UNKNOWN
           User is not known to an authentication module.

## SEE ALSO
       **pam**___**[authenticate**(3)](https://www.chedong.com/phpMan.php/man/authenticate/3/markdown), **pam**___**open**___**[session**(3)](https://www.chedong.com/phpMan.php/man/session/3/markdown), **pam**___**close**___**[session**(3)](https://www.chedong.com/phpMan.php/man/session/3/markdown), **pam**___**[strerror**(3)](https://www.chedong.com/phpMan.php/man/strerror/3/markdown)



Linux-PAM Manual                             06/08/2020                               [PAM_SETCRED(3)](https://www.chedong.com/phpMan.php/man/PAMSETCRED/3/markdown)
