3

Using the alfresco REST api, I've been able to query for usergroups and users, and been able to get users that are children of a specific group.

However, I now need to do the opposite; to know all the usergroup memberships of a certain user. I can't seem to find a webscript, or any other way to do it.

For implementation convenience, I'd rather not write a custom webscript, apart from not being familiar with how to do so.

Project setup

I'm programming in GWT/GXT, using Apache's openCMIS and calls to the RESTful api for alfresco.

I can load all the groups into alfresco, and then check every group's children for my user, but that doesn't seem the way to go since this functionality will be fired fairly often, and must be able to run smoothly on large implementation environments.

Mark Tielemans
  • 1,528
  • 3
  • 20
  • 40

1 Answers1

6

try calling /alfresco/service/api/people/{user}?groups=true

skuro
  • 13,414
  • 1
  • 48
  • 67
billerby
  • 1,977
  • 12
  • 22
  • Absolutely invaluable! For my future venturing into the api, where did you find out about the possible parameters? I found they're mentioned [here](http://docs.alfresco.com/4.0/topic/com.alfresco.enterprise.doc/references/RESTful-PersonPeopleGet.html) nor [here](http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference). – Mark Tielemans Jan 17 '13 at 14:01
  • 1
    A nice way to find out stuff like this is to use the inspect functionality in Google chrome (or firebug). In the network tab, click on XHR. With this open, enter Alfresco Share and for example the Admin gui and click on (for this particular example) a User in the user administration gui. You can then follow all webscript calls from share with immediatly. Click on response to see the resulting json. – billerby Jan 17 '13 at 14:10
  • +1 for using your tools to their full potential. Thanks for sharing! – Mark Tielemans Jan 17 '13 at 14:26
  • 1
    Just visit `/alfresco/service` and look at the webscript listing, that should tell you a fair bit about most of the APIs – Gagravarr Jan 17 '13 at 14:46
  • Thanks, I have to add that it won't work unless you add a backslash: `/alfresco/service/` – Mark Tielemans Jan 17 '13 at 21:58
  • I just noticed this script, like the alfresco dashboard, returns the usergroups of the user as expected, but also **their implicit parents up to the root group**. Do you know of a solution to this, or should I define a new question? – Mark Tielemans Jan 18 '13 at 13:35
  • @MarkTielemans I think you will have to loop through the resulting groups of your first call and then call the group API `/api/groups/{groupName}/children` and look at the resulting authorityType. – billerby Jan 19 '13 at 14:10
  • @ErikB, great thinking! That's what I implemented friday :). But looking at the size of some implementation environments, I may not want to keep with this solution forever. – Mark Tielemans Jan 20 '13 at 18:44