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
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.
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?
Similar script is used in InterSystems IRIS docker image to scramble passwords on startup.
A couple more comments:
Thank you for your feedback, John!
I have corrected the article!
Gevorg, I'm only seeing a corrected title. The body of the post still makes two references to namespace:
Guess this comes from Cut/Paste
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue