Article Gevorg Arutiunian · Aug 31, 2018 1m read

Change all passwords in a system

This code snippet changes all passwords in a system to a specified string. The two literal strings at the beginning of the snippet can be adjusted to edit the system or password string. The class method "test" runs the code:


Class eduardlebedyuk.changePasswords Extends %RegisteredObject
{
	ClassMethod test()
	{
        set ns = $namespace
	    zn "%SYS"
	    set NewPass = "NewPassString"
	    set rs=##Class(%ResultSet).%New("Security.Users:List")
	    set st = rs.Execute()
	    while rs.Next() { set st=$SYSTEM.Security.ChangePassword(rs.Get("Name"),NewPass)}
        zn ns
	}
}

(Originally posted on Intersystems CODE by @Eduard Lebedyuk, 10/8/2014)

Here's a link to the code on GitHub

Comments

John Murray · Aug 31, 2018

Be aware that this code sample changes the password of every user, including the CSPSystem account used by your CSP-enabled your web servers, including the private Apache instance that hosts the browser-based admin of your server. Changing that password may prevent you using Portal until you have made the corresponding change via the Web Gateway Management page.

0
Evgeny Shvarov  Aug 31, 2018 to John Murray

Thank you, John!

Actually, I don't know the case when we may need to change passwords for ALL users to the one specified.

So, don't run this code on your production system.

@Eduard Lebedyuk is there any close to reality case when this snippet could be useful?

0
Eduard Lebedyuk  Aug 31, 2018 to Evgeny Shvarov

Similar script is used in InterSystems IRIS docker image to scramble passwords on startup.

0
John Murray · Aug 31, 2018

A couple more comments:

  1. I'm not clear why the title and the body of the post refer to a "namespace". Security credentials are system-wide, not per-namespace.
  2. The method switches to the %SYS namespace in order to be able to run the List query of Security.Users, but it never switches back.
0
Gevorg Arutiunian  Sep 3, 2018 to John Murray

Thank you for your feedback, John!

I have corrected the article!

0
John Murray  Sep 3, 2018 to Gevorg Arutiunian

Gevorg, I'm only seeing a corrected title. The body of the post still makes two references to namespace:

0
Robert Cemper  Mar 28, 2020 to John Murray

Guess this comes from Cut/Paste

0