Objective

Admin password is forgotten and needs to be reset.

Environment

AEM 6.3, AEM6.4

Steps

  1. Enter the following command in the server command prompt (replace the path with the path to your AEM segmentstore

    java -jar oak-run-*.jar console path/to/crx-quickstart/repository/segmentstore --read-write :load admin-reset.groovy
    
  2. Oak-run should be launched in console mode, there should be a console with a leading /> to enter commands. If it does not work, then verify that the path to the segmentstore is correct.

  3. Enter the following:

    :load admin-reset63.groovy
  4. Press enter and the script will automatically find and change the admin password to admin.
    Review the output, it says:

    Found admin node : SegmentNodeBuilder{path=/home/users/some/path}
  5. Enter the following to exit console, stop the oak run jar before you can start AEM
    :q

  6. Start AEM

Additional information

Needed Items:

  • oak-run jar
  • admin-reset.groovy script (download/remove .txt or create from content)

Prevziať

import org.apache.jackrabbit.oak.spi.security.user.util.PasswordUtil
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook

class Global {
    static adminNode = null;
}

void findAdminNode(ub) {
    if (ub.hasProperty("rep:principalName")) {
        if ("rep:principalName = admin".equals(ub.getProperty("rep:principalName").toString())) {
            Global.adminNode = ub;
        }
    }
    ub.childNodeNames.each { it -> 
        if (Global.adminNode == null) {
            findAdminNode(ub.getChildNode(it));
        }
    }
}

ub = session.store.root.builder();
findAdminNode(ub.getChildNode("home").getChildNode("users"));

if (Global.adminNode) {
    println("Found admin node: " + Global.adminNode.toString());
    Global.adminNode.setProperty("rep:password", PasswordUtil.buildPasswordHash("admin"));
    session.store.merge(ub, EmptyHook.INSTANCE, CommitInfo.EMPTY);
} else {
    println("Could not find admin node.");
}

Licencia na používanie tohto diela sa poskytuje v súlade s podmienkami licencie Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Na príspevky v sociálnych sieťach Twitter™ a Facebook sa nevzťahujú podmienky licencií Creative Commons.

Právne upozornenia   |   Zásady ochrany osobných údajov online