Username string into PLC tag

How do I get the current username written into a PLC tag?
I’m using ControlLogix and Studio 5000 21.03

Write a Client Startup Script that writes the username to the PLC tag using the system.tag.write() function.

Use the system.security.getUsername() function to get the username of the logged in user.

Best,

That makes sense. hank you.
I’m not a script writer. Any way you could show me what that script might look like?
Thanks

user = system.security.getUsername() system.tag.write("PathToYourTag",user)

Here’s a video about Startup Scripts: inductiveuniversity.com/video/startup-scripts

Best,

Thanks
This is what my script looks like:
#Define Tech password as “1234”

Get the username from the System

#If the user is logged in as Tech, write “1234” to the PLC tag
#Write a “0” otherwise
Techpassword=1234
Username = system.security.getUsername()
if Username == ‘Tech’:
system.tag.write("[{PLC}]BAT_HMI/BAT_HMI.Code",Techpassword)
else:
system.tag.write("[{PLC}]BAT_HMI/BAT_HMI.Code",0)

This kind of security will get you in big trouble if there’s any chance for multiple clients opening this project. If one client opens it and is not ‘Tech’, then another client opens it simultaneously as ‘Tech’, the PLC will be in ‘Tech’ mode for both. If the tech opens first, he/she will lose tech access when the second client logs in.

You should not use a PLC global tag to control security for Ignition clients. Use Ignition’s security system. If you have a fixed location for a client that should have different default behaviors, check the client IP address or some other reliable indicator of that location then preset Ignition’s security using system.security.switchUser().