# Helper functions to change user context

cygwin_logon_user
3
Cygwin API Reference

## cygwin_logon_user

    #include <sys/cygwin.h>

    HANDLE
    cygwin_logon_user
    const struct passwd *passwd_entry
    const char *password

### Description

Given a pointer to a passwd entry of a user and a cleartext password, returns a HANDLE to an impersonation token for this user which can be used in a subsequent call to `cygwin_set_impersonation_token` to impersonate that user. This function can only be called from a process which has the required NT user rights to perform a logon.

### See also

See also the chapter Switching the user context in the Cygwin User's guide.

See also cygwin_set_impersonation_token

cygwin_set_impersonation_token
3
Cygwin API Reference

## cygwin_set_impersonation_token

    #include <sys/cygwin.h>

    void
    cygwin_set_impersonation_token
    const HANDLE token

### Description

Use this function to enable the token given as parameter as impersonation token for the next call to `setuid` or `seteuid`. Use `cygwin_set_impersonation_token` together with `cygwin_logon_user` to impersonate users using password authentication.

### See also

See also the chapter Switching the user context in the Cygwin User's guide.

See also cygwin_logon_user