# Force authentication of a user via script

**URL:** <https://forum.inductiveautomation.com/t/force-authentication-of-a-user-via-script/56132>\
**Category:** Ignition\
**Created:** [February 14, 2022, 8:55pm UTC](https://forum.inductiveautomation.com/t/force-authentication-of-a-user-via-script/56132 "2022-02-14T20:55:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuel.moye](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@samuel.moye](https://forum.inductiveautomation.com/u/samuel.moye)\
**Post date:** [February 14, 2022, 8:55pm UTC](https://forum.inductiveautomation.com/t/force-authentication-of-a-user-via-script/56132/1 "2022-02-14T20:55:17Z")

</div>

I have a legacy SCADA system “Wonderware” that writes the values firstname/lastname in a DB for a station and I want to use that data to authenticate the same user in ignition.

Can I use a query to “force” ignition to read the value from the db and login the same person? I am trying to make it easier for the person to leave the Legacy SCADA and not have to re-login to my ignition app.

Thanks!

---

<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:** [February 14, 2022, 10:10pm UTC](https://forum.inductiveautomation.com/t/force-authentication-of-a-user-via-script/56132/2 "2022-02-14T22:10:09Z")

</div>

I don’t understand how that authenticates anyone, but, taking the question at face value:  
Vision _does not_ allow you to login without some valid user. However, you can run scripts to _switch_ what user you are using ([`system.security.switchUser`](https://docs.inductiveautomation.com/display/DOC81/system.security.switchUser)).

I would do something like the following:

1. Have a bare project with auto-login enabled. This project’s _only_ purpose will be to display some intermediate ‘loading’ graphic for a split second before the rest of this process kicks off.
2. On startup of that project, use scripting to query the DB (?) for the authentication info, then pass it to `switchUser`.
3. Call [`system.util.retarget`](https://docs.inductiveautomation.com/display/DOC81/system.util.retarget) to swap from the ‘empty’ project with the autologin user to the real project (now that you’re authenticated).

You need the second project so that auto-login isn’t a confusing/misleading operation on your real project, and to make it easier to lock down the main project.

---

<div class="post-metadata">

**Author:** ![samuel.moye](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@samuel.moye](https://forum.inductiveautomation.com/u/samuel.moye)\
**Post date:** [March 11, 2022, 2:36pm UTC](https://forum.inductiveautomation.com/t/force-authentication-of-a-user-via-script/56132/3 "2022-03-11T14:36:12Z")

</div>

Sorry I didn’t specify this, I’m developing this project in perspective. The switchuser function doesn’t work in perspective. If I have the string “B.Johnson” I want to force perspective to authenticate “B.Johnson” from my Active directory source in my project.
