Page tree
Skip to end of metadata
Go to start of metadata

Your Rating: Results: 1 Star2 Star3 Star4 Star5 Star 120 rates

Here's a Groovy script to reset all the passwords in our database to "". We used this when we went from Magnolia's native authentication to using LDAP.

import info.magnolia.jcr.util.NodeUtil
import info.magnolia.jcr.predicate.NodeTypePredicate
import info.magnolia.jcr.util.NodeTypes
session = ctx.getJCRSession("users")
users = NodeUtil.collectAllChildren(session.rootNode, new NodeTypePredicate(NodeTypes.User.NAME))
int count = 0
users.each() {
    if (it.name != "anonymous" && it.name != "superuser" ) {
        it.setProperty("pswd", "")
        it.save()
        count++
    }
}
println("Reset password for " + count + " users.")
println("Passwords for user \"anonymous\" and \"superuser\" remain unchanged.")