Skip to content

Instantly share code, notes, and snippets.

@flox1an
Last active July 21, 2023 17:40
Show Gist options
  • Save flox1an/5956294 to your computer and use it in GitHub Desktop.
Save flox1an/5956294 to your computer and use it in GitHub Desktop.
Webscript to create a new (emergency) admin user in Alfresco. 1. Copy to alfresco/extension/templates/webscripts/ 2. restart Alfresco 3. Call the URL: http://localhost:8080/alfresco/service/server/createadmin 4. Log in with localadmin / localadmin
<webscript>
<shortname>create admin user</shortname>
<description>creates an user called localAdmin and add it to the admingroup</description>
<url>/server/createadmin</url>
<format default="json">argument</format>
<authentication runas="admin">none</authentication>
<transaction>required</transaction>
</webscript>
function createUser(username, firstname, lastname, email)
{
var password = username;
var p = people.createPerson(username, firstname, lastname, email, password, true);
if (p) p.save();
}
function main()
{
var userName = 'localadmin';
createUser(userName, 'Local','Admin', 'admin@alfresco.com');
var adminGroup = groups.getGroup('ALFRESCO_ADMINISTRATORS');
adminGroup.addAuthority(userName);
}
main();

Webscript to create a new (emergency) admin user in Alfresco.

  1. Copy to alfresco/extension/templates/webscripts/
  2. restart Alfresco
  3. Call the URL: [http://localhost:8080/alfresco/service/server/createadmin]
  4. Log in with localadmin / localadmin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment