Change pw in db user source with script

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

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.

The system.user.addUser documentation has an example for adding a user/password to a user source. The 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.

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 that provide similar functionality.

1 Like

Thank you! :star_struck:

Than you very much!