CreateUser
- Last UpdatedOct 29, 2026
- 3 minute read
The function CreateUser creates a new user in your project's security system.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
CreateUser |
Security |
Synchronous |
No |
Supported |
Supported |
Not supported |
Supported |
Not supported |
Syntax
CreateUser(optStrUserName,optStrGroup,optStrPassw,optStrUserFullName)
CreateUser ( { | optStrUserName,optStrGroup { | ,optStrPassw { | ,optStrUserFullName } } } )
optStrUserName,optStrGroup
The name of the user to be created, and the group(s) to which the user will belong. You can specify multiple groups by separating them with a comma.
These are optional parameters; if no values are specified, a dialog box will be displayed on the client so that the current user can provide the information.
optStrPassw
The user's password.
This is an optional parameter; if no value is specified, the user will not have a password. (To specify one later, either call the function SetPassword or edit the user's settings in the project security system.)
optStrUserFullName
The full name of the user.
This is an optional parameter; if no value is specified, the user will not have a full name. (To specify one later, edit the user's settings in the project security system.)
Returned value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
-1000 |
Could not display dialog box. The function should executed on the client. |
|
-1 |
Internal error. Please contact Support. |
|
0 |
New user created successfully. |
|
1 |
Invalid number of parameters. |
|
2 |
Wrong parameter type. |
|
3 |
User name already exists. |
|
4 |
Group does not exist. |
|
5 |
Failed to save to configuration file. |
|
6 |
Invalid user. |
|
7 |
User full name already exists. |
|
8 |
Reentrant function call not allowed. |
|
9 |
User clicked Cancel on the Create User dialog box. |
|
10 |
Invalid password, check the minimum password size specified for the group. |
|
11 |
Invalid group. (Group may not have Runtime group option selected.) |
|
12 |
Create User dialog box is already displayed, cannot display another dialog box. (For example, if the user clicked OK without providing all of the required information.) |
|
13 |
The current user does not have sufficient privileges to make changes (that is, the current user does not belong to a group that has the Edit Security System option selected). |
|
14 |
The current Security Mode does not allow a user to be created. |
Notes
When you use this function to create a user, the Runtime user option is selected in the account settings for that user. For more information, see Creating and configuring users.
You should avoid calling this function too frequently during project run time — for example, as part of a For loop that repeats in a matter of milliseconds. By default, the security settings are saved synchronously (that is, after each change is made), and too frequent saves can decrease runtime performance and/or cause the project development environment to freeze.
As a workaround, you can change the default behavior and configure your project to save the security settings asynchronously, at a specified interval. To do this, manually edit your project file (<project name>.app) to add the following settings:
[SecuritySystem]
EnableAsyncSavingForBuiltInFunctions=1
[Options]
SecuritySystemAutoSaveInterval=<in minutes, default is 5, minimum is 1>
Asynchronous saving applies to the following built-in functions:
-
BlockUser
-
CreateUser
-
RemoveUser
-
SetPassword
-
SetUserGroup
-
UnblockUser
If you enable asynchronous saving as described above and then call any of these functions to make changes to the security settings during project run time, those changes will be applied immediately but they might not be saved when the project is stopped.
In contrast, if you use the project development environment to make changes to the security settings during project run time, those changes are always saved synchronously regardless of whether asynchronous saving is enabled.
Examples
Display the Create User dialog box on the client, to get the information from the current user:
CreateUser()
Create a user named "Bob" in the group "Admin", with the password "Chocolate":
CreateUser("Bob","Admin","Chocolate")
Create a user named "Albert" (full name "Albert Jones") in the group "Engineering", with the password "EMC2":
CreateUser("Albert","Engineering","EMC2","Albert Jones")