Detect User Login Across All Clients

There is a way to detect what User is logged in to a specific client. But is there a way to detect whether any of the clients connected to the gateway has a certain role of access?

You can find out what role logged in user has.

But why do you need to know, and how would you want to use that info?

The specific application is that I want to change the mode my machine is in if the user logged in doesn’t have the proper role to access the mode the machine is currently in. So I need to detect across all clients, if any of them have the proper role to access the current mode in the machine. To do that I would need to know across all clients, which roles are logged in.

If Vision, you can use system.util.getSessionInfo() to get a dataset that includes each active user’s username.

You can then use system.security.getRoles() to retrieve that username’s roles, and check if they have your specific values.

If Perspective, you’ll have a different path depending on what IdP you’re using and some other wrinkles.

1 Like

That should work for me. Thank you.

Is there a way to get this in an tag without having a timer script constantly writing the dataset to a tag?

You can use the runScript expression in a tag.
https://docs.inductiveautomation.com/display/DOC81/runScript

The timer script has the advantage that it could compare the content each time it runs to avoid writing a new dataset, and thereby avoid unnecessary change events in subscribers.