Article
· 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

Discussion (7)2
Log in or sign up to continue

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.