Alfresco, massive delete of users

Since Share web interface nor admin web console have option to delete massively users, this operation has to be performed by your own rules.

I’m using Javascript Console to make easier the execution of Administration JavaScripts, but any other tool (even curl) can be used.

// Get every user in Alfresco
var nodes = people.getPeople(null);
for each(var node in nodes) { 
  // Build user object
  var user = utils.getNodeFromString(node);
  // Obtain userId
  var userName =["cm:userName"];
  // Obtain userHomeFolder
  var userHomeFolder =["cm:homeFolder"];
  // Filter users to be deleted by any criteria, starting by "CES" in this case
  if (userName.indexOf("CES") == 0) {
      logger.log(userName + ", " +["cm:name"]);
      // people.deletePerson(userName);
      // userHomeFolder.remove();

Once you have verified that every userName logged by this script has to be deleted, you can uncomment following lines…

      // people.deletePerson(userName);
      // userHomeFolder.remove();

… and run the script again to perform effectively the removal.

As other Alfresco community members have pointed out by Twitter and LinkedIn, this script is just a sample for your understanding. Many other factors (LDAP, repository permissions, ownership over contents…) have to be considered before using a script like this in a real environment.



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s