# Change pw in db user source with script

**URL:** <https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [November 26, 2021, 3:42pm UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492 "2021-11-26T15:42:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakned](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jakned](https://forum.inductiveautomation.com/u/jakned)\
**Post date:** [November 26, 2021, 3:42pm UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492/1 "2021-11-26T15:42:44Z")

</div>

Hi, I would like to have users manage database user source from perspective session and would like to ask you guys how to process the password before storing it.  
I guess that with MySQL query I could use MD5() function but we use MSSQL.

Thanks for advice

---

<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:** [November 26, 2021, 4:01pm UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492/2 "2021-11-26T16:01:40Z")

</div>

~~No, not available even for MySQL. Ignition has to encrypt passwords on its end **reversibly** so that the plain text can be hashed with challenges in each DB type’s JDBC API. If you dig around in the SDK API docs you can figure it out. (Please _ **don’t** _ post the details when/if you do.) Plus you’d have to manipulate Ignition’s internal DB. Also possible with SDK APIs, but doing so is utterly unsupported.~~

 

Good luck.

~~And no, I am not willing to provide more info privately, either.~~

Hmm. Must pay closer attention. Database user source != Database connection.

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [November 26, 2021, 8:26pm UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492/3 "2021-11-26T20:26:21Z")

</div>

The [system.user.addUser](https://docs.inductiveautomation.com/display/DOC81/system.user.addUser) documentation has an example for adding a user/password to a user source. The [system.user.editUser](https://docs.inductiveautomation.com/display/DOC81/system.user.editUser) function could probably be used in a similar manner to change a password.

The following, incomplete code, works for database user sources in 7.8 and 7.9. I have not tried it in newer versions.

```auto
from com.inductiveautomation.ignition.common.util import SecurityUtils
SHA1 = SecurityUtils.sha1String(passwordNew)
query = "UPDATE zAuthusers SET passwd=? WHERE username=?"
system.db.runPrepUpdate(query, [SHA1, username])

```

There are also projects on the [Exchange](https://inductiveautomation.com/exchange/2128/overview) that provide similar functionality.

---

<div class="post-metadata">

**Author:** ![jakned](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jakned](https://forum.inductiveautomation.com/u/jakned)\
**Post date:** [November 27, 2021, 6:18pm UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492/4 "2021-11-27T18:18:40Z")

</div>

Thank you! 🤩

---

<div class="post-metadata">

**Author:** ![471421143](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/471421143/32/38211_2.png) [@471421143](https://forum.inductiveautomation.com/u/471421143)\
**Post date:** [May 21, 2023, 2:37am UTC](https://forum.inductiveautomation.com/t/change-pw-in-db-user-source-with-script/53492/5 "2023-05-21T02:37:37Z")

</div>

Than you very much!
