cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the list of users

anweber
Champ in-the-making
Champ in-the-making
Hi,

   How is  it possible to find the list of users via a code written in JS?

   I tried that:

   log("============= begin");
   var results;
   var i;
   var result;
   var searchString = "TYPE:\"{http://www.alfresco.org/model/user/1.0}user\"";
   log("users");
   
   results = search.luceneSearch(searchString);
   log ("nb =" + results.length);
   
   for (i in results){
      log(results[i]);
   } 
   log("=============== End");


I obtain no nodes.  But this Lucene search string works in the node browser.

  Thanks for your help,

              Andre

PS : In the documentation about the JavaScript API (see http://wiki.alfresco.com/wiki/JavaScript_API, the example is  not correct :

var nodes = luceneSearch("TEXT:alfresco");
should be written

var nodes = search.luceneSearch("TEXT:alfresco");
6 REPLIES 6

kevinr
Star Contributor
Star Contributor
I tried your search in the NodeBrowser - and it works but only against the alfrescoUserStore. All searches in the JavaScript API world run against the default SpacesStore.

I have corrected the documentation - thanks for spotting that.

Cheers,

Kevin

anweber
Champ in-the-making
Champ in-the-making
Hello Kevin,

    Thanks for your quick answer.  But it doesn't solve my problem : how can I obtain the list of users from JavaScript code.

         Regards,

                Andre

anweber
Champ in-the-making
Champ in-the-making
Hi,

   I have found a solution : information on the users are stored in the defaultStore with instances of "cmSmiley Tongueerson".


   var searchString = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
   log("users");
   
   results = search.luceneSearch(searchString);
   log ("nb =" + results.length);
   
   for (i in results){
      log(results[i]);
   } 
   log("=============== End");


   Now, I should like to obtain the name of the homeFolder of each user (or person) but my script has not always the "Read" right on those folders (I was expecting to find the name of this folder directly in the "person" object,  but in this object I find the reference of the homeFolder and not its name - with this reference, I am not able to find the name because I do not have the "Read" right on this object).  Anyway, it's already a progress!  

   Thanks for your help,

           Andre

andy
Champ on-the-rise
Champ on-the-rise
Hi

If the user is running the code has admin rights, they will be able to see the information.

If not why, should they see it?

Regards

Andy

anweber
Champ in-the-making
Champ in-the-making
Hi,

  I try to develop a workflow using a script (in JavaScript).  Each user should "see" in the webClient only his homeFolder and subFolders.  But, some workflow actions triggered by the current user have to write into some folder of an other user.  I found a way to do that : each user has access to his homeFolder (and subFolders) and access to some subFolders in the homeDirectory of others users (folders where the workflow has to have access).  Then in the webClient, a user do not see folders of others users (except via a search).  The API let me access to a folder if I have enough rights on this folder even if I have not any rights on its parent folder.  Then, the only difficulty I have to solve is to obtain the path of the target folder; it's because I try to obtain the name of the homeFolders of others users (for the users selected as actors of my workflow) when I do not have the "Read" right on those homeFolders .

    I hope it's clear enough.

          Regards,

               Andre

andy
Champ on-the-rise
Champ on-the-rise
Hi

You can not find the path to a folder if you do not have access to all the parents. You would have to refer to these folders by id rather than path.

Regards

Andy