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 = user.properties["cm:userName"];
  // Obtain userHomeFolder
  var userHomeFolder = user.properties["cm:homeFolder"];
  // Filter users to be deleted by any criteria, starting by "CES" in this case
  if (userName.indexOf("CES") == 0) {
      logger.log(userName + ", " + userHomeFolder.properties["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.

Anuncios

Responder

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

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. 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 )

Google+ photo

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

Conectando a %s