# Detect User Login Across All Clients

**URL:** <https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 18, 2022, 4:05pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117 "2022-01-18T16:05:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 18, 2022, 4:05pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/1 "2022-01-18T16:05:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [January 18, 2022, 4:32pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/2 "2022-01-18T16:32:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 18, 2022, 5:36pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/3 "2022-01-18T17:36:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 18, 2022, 5:49pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/4 "2022-01-18T17:49:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 18, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/5 "2022-01-18T17:52:42Z")

</div>

That should work for me. Thank you.

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 19, 2022, 8:51pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/6 "2022-01-19T20:51:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 20, 2022, 4:00pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/7 "2022-01-20T16:00:22Z")

</div>

You can use the `runScript` expression in a tag.  
[https://docs.inductiveautomation.com/display/DOC81/runScript](https://docs.inductiveautomation.com/display/DOC81/runScript)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2022, 4:10pm UTC](https://forum.inductiveautomation.com/t/detect-user-login-across-all-clients/55117/8 "2022-01-20T16:10:48Z")

</div>

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.
