How-to
PLC triggered user login by alias on a unified panel
Short answer
From V19 Update 2, SetzeLokalenBenutzer (SetLocalUser in the English documentation) logs the local WinCC Unified user in from an alias string a PLC supplies; PC Runtime needs Login mit RFID aktivieren selected first, and web clients are excluded. Unified tags have no value-change event, so trigger a script dynamized on an unused property of an object in the main screen window, guard it against an empty alias, and let the function clear the tag after each login.
On this page
A PLC can put the right user in front of a WinCC Unified machine: from V19 Update 2 the system function SetzeLokalenBenutzer, listed as SetLocalUser in the English documentation, reads an alias string from a tag, logs in the local user mapped to it and empties the tag afterwards. On Unified PC Runtime you must first select the option Login mit RFID aktivieren in the WinCC Unified Configuration tool; a Comfort Panel needs no such step. Web clients are outside this path. Because a Unified HMI tag raises no value-change event of its own, the automatic version runs the function from a script that dynamizes an unused property of an object in the main screen window, with the alias tag as the script trigger. This article sets the chain up in order: version, alias, PC option, button test, script.
Check the version and the target session #
Read the installed Runtime version first. The alias function exists from V19 Update 2, released 05/2024, on Unified Comfort Panels and in Unified PC Runtime; this configuration follows the documentation as it stood in July 2024, so recheck your exact build against its own release notes. If the function is missing from the system function list, the version is the blocker and nothing downstream will work.
Then fix the session. The function switches the local session only — the user on the panel, or the user on the computer running PC Runtime. Browser sessions on the same runtime are a separate scope, which what publishing HMI runtime screens to web clients requires explains, and this function does not reach them. If the target really is a web client, use the login mechanism documented for that client instead.
If you would rather send a username and password from the controller, that is a different function, WechseleBenutzer, added with V20. The alias path keeps passwords out of the PLC link entirely, which is what makes it suitable for a controller-triggered login.
Assign an alias to each user the PLC will log in #
Open the users and roles table of the project, named Benutzer und Rollen. The alias column is hidden by default: right-click a table header and enable the alias display, then give every account the PLC may log in a short, unambiguous alias. The alias parameter is a String, and the login goes to whichever account carries the matching alias.
Compare the value the PLC sends with the configured alias character for character. A leading space, a truncated string or a wrong tag connection produces a valid-looking request that matches no account. After a test login, run one role-controlled action: if the correct user is active but access is wrong, the role assignment is the fault, not the trigger.
Select the login option on PC Runtime #
On the PC Runtime computer, start the tool WinCC Unified Configuration and select the checkbox Login mit RFID aktivieren, which means activate login with RFID; the notes for the V19 updates name this as the setting that enables the alias function there. A Unified Comfort Panel has no equivalent step.
The checkbox borrows its label from badge login, the reader-based flow described in RFID card login on a Comfort Panel with PM-LOGON Basic, but this login attaches no reader and presents no badge: the alias arrives as an ordinary tag value, and the option only unlocks the function.
Prove the login on a button first #
Automate nothing until a button proves the account side. Attach SetzeLokalenBenutzer to a button event and configure the parameter as either the alias tag or a link to an input/output field holding the alias. Then work through these checks:
- Put a configured alias into the tag or the linked field.
- Operate the button once.
- Confirm the active user switches to the mapped account.
- Read the alias tag again: it is empty, because the function reads the alias, logs the user in and then clears the value.
- Run one role-controlled action to confirm the roles moved with the user.
A failure at this stage is an alias mismatch, a session-scope problem or a missing PC Runtime option — fix it before adding any trigger.
Worked case: a hidden object in the main screen window fires the login #
The inputs, with their sources:
- Runtime: a Unified Comfort Panel at V19 Update 2, so no PC-side option applies (release notes).
- Alias tag: a String tag the PLC program fills — the value OP2 for the second operator account, for example, is an illustrative mapping you define yourself.
- Trigger carrier: one object in the main screen window, the window that stays loaded whatever screen is displayed; a rectangle is typical, and it is invisible (the method calls for a hidden object).
- Dynamized property: Fenstereinstellung, a window-settings property this application uses for nothing else (the method's example property).
- Script trigger: the alias tag itself.
The rule, in words: a Unified HMI tag has no value-change event of its own, and the task scheduler cannot execute this function, so the event is manufactured on a loaded screen — dynamize an unused property by script, set the script trigger to the alias tag, and call the login from the script only when the alias is non-empty. Configure it in this order:
- Place one object in the main screen window and make it invisible; it carries the trigger, it displays nothing.
- Dynamize the property Fenstereinstellung on that object by script.
- Set the script trigger to the alias tag, not to a time cycle.
- In the script, return immediately on an empty alias; otherwise call SetzeLokalenBenutzer with the alias.
- Arm the request from the controller and watch the login: the user switches and the tag clears. Testing HMI simulation against a live PLC shows how to watch tag traffic against a live controller before you trust the trigger.
The illustrative decision logic — my variable names; SetzeLokalenBenutzer is the documented function:
// Trigger of this script: the alias tag from the PLC
let alias = current value of the alias tag; // String, empty when no request is pending
if (alias) { // non-empty only
SetzeLokalenBenutzer(alias); // logs in the mapped user, then clears the tag
}
Now the arithmetic that decides the handshake. The function empties the tag after each login, so every non-empty write is one request. If the PLC program rewrites the alias on a 1 s cycle of its own, each clear survives less than one cycle: 1 write each second × 60 s = 60 login requests a minute for the same account. The empty-value guard does not reduce this — it only stops the script from acting on the cleared value. The fix lives in the PLC: write the alias once per rising request and hold off until the tag reads back empty.
The result: with the trigger on the tag and the guard in place, one PLC write produces exactly one login; the clear that follows may re-trigger the script once, and the guard makes that pass do nothing. The decision for each case: on the panel, run the case as configured; on PC Runtime, select the configuration-tool option first; on web clients, do not use this function at all.
Keep the request single-shot #
The alias tag is a consumable request, not a held identity command. An empty tag means no pending request, not an empty session; the runtime's active-user display is the login result, and displaying the requested alias proves only that the value arrived. Own each transition once: the PLC publishes on a rising operator action, the panel consumes, and the empty readback arms the next request. Level-holding logic and this function do not mix — a tag that stays non-empty logs the same user in again after every clear.
This path pulls an identity into the HMI only. Sending the active user back to the PLC is the opposite direction and is covered in Sending the active HMI user to the PLC with login macros.
Limits and one safety note #
Deploy against the full list: alias parameter as a String, local session only, PC Runtime behind its configuration option, and one login request per non-empty write. Treat the alias tag as an authorization input: restrict its write access to the approved PLC logic and the network path that carries it, and restrict who may edit the alias mapping in the project. One safety note: a login driven from the controller must never stand in for a safety function — the gate that protects a person belongs to the safety system, not to an HMI session, whatever user is active.
Questions asked
The alias reaches the panel but nobody is logged in — what do I check?
A displayed alias proves the tag arrived, not that the login ran. Confirm the script trigger is set to the alias tag itself, the dynamized object sits in the main screen window so it is loaded in every screen, the incoming text matches the configured alias exactly, and on PC Runtime the login option in WinCC Unified Configuration is selected. Then retest on a button before trusting the script.
Does Login mit RFID aktivieren mean I need a badge reader on PC Runtime?
No. The checkbox in the WinCC Unified Configuration tool unlocks the alias-based login; no reader is attached and no badge is presented. Badge login with a reader is a separate mechanism, and the two share only the name on that checkbox.
Can the PLC send a username and password instead of an alias?
Not with this function: its parameter is a String alias, and it deliberately keeps passwords out of the PLC link. A username-and-password login, WechseleBenutzer, exists from V20. Whichever function you use, restrict write access to the request tag, because a single write changes the identity the machine acts on.
How do I stop a cyclic PLC write from logging the same user in repeatedly?
The function clears the alias after each login, so make the PLC write once per rising request and wait until the tag reads back empty before it arms the next one. A program that rewrites the alias on every cycle overwrites each clear and produces a login attempt every cycle.
Does the script run again when the function clears the alias?
It can: the trigger watches the tag, and the clear is a tag update like any other. The empty-value guard is what makes that pass harmless — the script reads an empty alias and returns without calling the login, so one request still produces exactly one login.