cancel
Showing results for 
Search instead for 
Did you mean: 

accessing all users in java class

chuck
Champ in-the-making
Champ in-the-making
Hi,
Can anyone please point me in the right direction. I am trying to access a list of all the users in the system.

I wish to do this in my java class. I am thinking the UsersBean might be helpful but would appreciate some pointers or a snippet of code of how to do this in my java class.

Thanks,
Chuck
1 REPLY 1

kevinr
Star Contributor
Star Contributor
Yes the UsersBean has example code which does what you want, it calls a helper on the client Repository util class called getUsers().

The People are stored under a special node retrievable from the PersonService. So something like this:

         NodeRef peopleRef = personService.getPeopleContainer();
         List<ChildAssociationRef> childRefs = nodeService.getChildAssocs(peopleRef);
         for (ChildAssociationRef ref: childRefs)
         {
            // get the NodeRef of the person
            NodeRef personRef = ref.getChildRef();
            if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_PERSON))
            {
               … do some work with person properties here …
            }
         }

Thanks,

Kevin