Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Edge HMI

BlockUser

  • Last UpdatedOct 29, 2026
  • 2 minute read

BlockUser is a built-in function that blocks an existing user from logging onto a project. This allows you to disable a user account without deleting it.

Function

Group

Execution

String Exp.

Windows

Windows Embedded

IoT View

Thin Clients

Mobile Access

BlockUser

Security

Synchronous

No

Supported

Supported

Supported

Supported

Supported

Syntax

BlockUser(strUserName)

BlockUser ( strUserName )

strUserName

The name of the user to block.

Return value

This function returns one of the following possible values:

Value

Description

0

Success; the specified user is blocked.

1

Invalid number of parameters.

2

Wrong parameter type.

3

The specified user does not exist.

4

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).

5

The operation on the distributed security system failed.

6

N/A

7

The current security mode does not allow user to be blocked/unblocked.

8

Internal error.

Notes

When this function is used to block a user, the User is blocked option is selected in the account settings for that user. Subsequently, you can either call the UnblockUser function or manually clear the option in the User Account dialog box. For more information, see Blocking or unblocking a user.

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

Block the user named Bob:

BlockUser("Bob")

Block the user named in position 3 of the array badUsers:

BlockUser(badUsers[3])

Block the user who is currently logged on, as determined by the system tag UserName:

BlockUser(UserName)

In This Topic
Related Links