Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2026.1

# ClientApi::SetUser( const char * )

Sets the user for this connection.

Virtual? | No |
Class | `ClientApi` |
Arguments | `const char *c` | the new user name setting
Returns | `void` |

## Notes

`SetUser()` does not permanently set the `P4USER` value in the environment or registry. Calling this method is equivalent to using the "-u" global option from the command line to set the user value for a single command, with the exception that a single `ClientApi` object can be used to invoke multiple commands in a row.

If the user setting is to be in effect for the command when it is executed, you must call `SetUser()` before calling `Run()`.

## Example

The following example displays two user specifications by calling `SetUser()` between `Run()` commands.

    ClientApi client;
    Error e;

    char *args[1];
    args[0] = "-o";

    client.SetUser( "user1" );
    client.SetArgv( 1, args );
    client.Run( "user", &ui );

    client.SetUser( "user2" );
    client.SetArgv( 1, args );
    client.Run( "user", &ui );

Your search for returned results