AnsweredAssumed Answered

Hos to get full list of users & their belonging groups ?

Question asked by msevestre on Aug 5, 2009
Latest reply on Apr 1, 2010 by ilazki
Hello

I'm trying to generate a file with a JS script to help me to administrate users & group: I'd like to obtain a list with full clear test of user names & groups which they are attaached to ?

I tried to create a Javascript script that is nearly working, but I am not able to display "readable" user names & groups.

Here is the current source code:

var gens = people.getPeople(null);

var logFile = space.childByNamePath("log_users.txt");
if (logFile == null) {
   logFile = space.createFile("log_users.txt");
}
logFile.content = "";

for (var i=0; i<gens.length;i++) {
  logFile.content += gens[i]+"\n";

  var groupes= people.getContainerGroups(utils.getNodeFromString(gens[i]));

  for (var j=0; j<groupes.length;j++) {
    logFile.content += "\t"+groupes[j].name+"\n";
  }

}

I currently have an output of this kind :

workspace://SpacesStore/71a950d8-f26b-40ee-a496-51133147c345
   GROUP_ALFRESCO_ADMINISTRATORS
   d60ba031-128f-408e-aaa4-de69ce7ddd95
   e7252aad-8ef9-4986-90bd-7664e86384ab
workspace://SpacesStore/a0f6862c-ebb3-432f-b36e-4ba7076a2dc2
workspace://SpacesStore/8cb10f0a-eb91-4e12-96c8-c9321c6d8a08
workspace://SpacesStore/b019d0ee-c45d-44ea-b750-e0aeedf85abb
   GROUP_ALFRESCO_ADMINISTRATORS
   d60ba031-128f-408e-aaa4-de69ce7ddd95
   e7252aad-8ef9-4986-90bd-7664e86384ab

as you can see, user names have a "workspace://" type (using .name property give me "undefined" for all users). Groups are with a reference, except for basic groups (GROUP_ALFRESCO_ADMINISTRATORS, EMAIL, etc.) that are displayed clearly.

Note: if any other script exists, no problem to froget mine to use another one :)

Thanks for any help
Matt

Outcomes