Hi All,
I am looking at changing the way we are handling our badging in and out of ignition. I currently have a working method (With the help of some AI tools) and want to get some feedback on how I set it up. I am still learning the basics of ignition and scripting, so all help and feedback is welcomed. All scripts below.
Feedback:
-
Any risks I’m overlooking?
-
More efficient scripting?
-
A better method?
-
General feedback?
Current environment:
-
Ignition 8.1 vision.
-
A dozen terminals in the field.
-
We are running Thin manger and Thin Clients to visualize projects.
-
Pure AD.
-
Using the basic string that comes from thin clients and parsing that data to get the user requesting to sign in.
-
Using that Username to query a password database.
-
Using “Switch user” to force a sign in.
-
New users must be set up in, AD, Thin manger, and the database.
-
Users simply swipe badges for signing in and sign-out.
-
Access is heavily controlled with user roles.
-
Use Auto login.
The change I am thinking of trying is using the users RFID as their password and adding that to a custom variable in AD which then is set up as a badge attribute in ignition. I would then use the RFID reader as a wedge and run a keystroke script to set focus on a text field that writes to a client tag. I then have a change event script setup monitoring the tag. The script then looks for the badge attribute, gets the username associated to the RFID and then signs in with the username and password using “Switch user.”
I know there is risk in that passwords could be easily captured or scanned. We would plan on only using this for floor level screen users and if they have the need to be a domain user or high level then just basic operation access we would issue them a separate username and password for that.
Still haven’t figured out how to force a logout based on a time out situation.
Tag Change Script:
# --- Exit early if suppression flag is set ---
if system.tag.readBlocking(["[Client]RFID_Suppress"])[0].value:
system.tag.writeBlocking(["[Client]RFID_Suppress"], [False]) # Reset the flag
exit() # Don't process the scan
# --- Config ---
rfidTag = "[client]RFID"
defaultUser = "xxxxxxx"
defaultPass = "xxxxxxx"
userSorce = "ActiveDirectory"
# --- Read scanned RFID ---
rfidVal = system.tag.readBlocking([rfidTag])[0].value
rfid = str(rfidVal).strip() if rfidVal is not None else ""
if not rfid:
system.security.switchUser(defaultUser, defaultPass)
else:
# Build badge → username map
badgeUsername = {}
for user in system.user.getUsers(userSorce):
badge = user.get("Badge")
uname = user.get("username")
if badge and uname:
badgeUsername[str(badge).strip()] = str(uname).strip()
if rfid in badgeUsername:
username = badgeUsername[rfid]
currentUser = system.security.getUsername()
if currentUser == username:
system.security.switchUser(defaultUser, defaultPass)
else:
system.security.switchUser(username, rfid)
else:
system.security.switchUser(defaultUser, defaultPass)
system.gui.messageBox('Signed into default user', 'No Badge Found')
# --- Reset RFID tag to zero without retriggering ---
system.tag.writeBlocking(["[Client]RFID_Suppress"], [True]) # Turn on suppression
system.tag.writeBlocking([rfidTag], [0]) # Reset tag
Key Stock Script “SHIFT + F8”:
# Replace 'YourWindowName' with the name of the window that contains your Badge field
window = system.gui.getWindow('Main Window')
# If Badge is a direct child of the Root Container
badge_field = window.rootContainer.getComponent('Badge')
# Give focus to it
badge_field.requestFocusInWindow()