cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP request get user group via RESTful api

newcomer
Champ in-the-making
Champ in-the-making
I am talking with Alfresco Repository via RESTful api.

After an user login over HTTP, I wanted to get user details, like user name and groups.

I'm using Alfresco 3.4.2, and now I'm trying to get all the groups that a users belongs to (the user that login in my application)

I follow the alfrescowiki online, the url is "/alfresco/service/api/people/{username}" isn't work, and I play around, finally, /alfresco/service/api/people?username={username}, returns json with all the users in the system, but it doesn't have group information.


Is possible to get those groups?
Can any of you help me?

Thanks in advance.
2 REPLIES 2

newcomer
Champ in-the-making
Champ in-the-making
Please help

I tried use Group API, but it returns empty. But the groups are there in the Alfresco Explorer.

Please help

rahul_mackdani
Champ in-the-making
Champ in-the-making
var currentUserName = person.properties.userName;   //currentUserName  is currents used id

var currentPerson = people.getPerson(currentUserName);   //currentUserName  can be replaced by userid
var groups = people.getContainerGroups(currentPerson);

http://wiki.alfresco.com/wiki/3.4_JavaScript_Services_API#Groups_.28Authority_Service.29

Then you can iterate groups and use any nethod of groups(Refer)
for(var i=0;i<groups.length;i++)
{
   logger.log("User Group  in loop "+groups.getFullName());
}