cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript To list Groups

gmurphy
Champ on-the-rise
Champ on-the-rise
Folks,

To was tring to develope a webscript to list the current groups on my Alfresco instance. Has anyone any suggestions.

Any help would be greatful.

Regards,

Gerald
7 REPLIES 7

rliu
Champ in-the-making
Champ in-the-making
Try using the AuthorityService.getAllAuthorities(AuthorityType.GROUP).

That should get you a set of user groups defined in your instance.

Rich

bertrandf
Champ on-the-rise
Champ on-the-rise
For Alfresco 3.1 :
search.luceneSearch("user://alfrescoUserStore", "TYPE:\"usr:authorityContainer\"")
or
var groups = search.xpathSearch("user://alfrescoUserStore", "/sys:system/sys:authorities/*");

For Alfresco 3.2 : http://wiki.alfresco.com/wiki/3.2_JavaScript_Services_API#Groups_.28Authority_Service.29

sgomez
Champ in-the-making
Champ in-the-making
I had a difficult time looking for something similar to the example webscript from api/people ( people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);) with regards to getting groups, but the posts by rliu and bertrandF were very helpful.  Rliu's is great for java-backed webscript and BertrandF's for javascript webscript.

mrogers
Star Contributor
Star Contributor
3.2 already has web scripts for groups.   They are how the share admin console works.

Look at the online doc for
/api/groups
/api/rootgroups

svast
Champ on-the-rise
Champ on-the-rise
Please, as I am losing neurons on this…
Any code / snippet to list groups with the necessary 'import' clause?

I am using it like that:
 model.groups = AuthorityService.searchGroups()

and getting the following exception:
La classe Java "org.alfresco.service.cmr.security.AuthorityService" ne possède aucun champ ou aucune méthode d'instance publique appelé "searchGroups"

Server:   Alfresco Community v3.2.0 (2039) schema 2 019

mrogers
Star Contributor
Star Contributor
What's wrong with /api/groups ?

Have a look at the existing code rather than wasting brainpower.

svast
Champ on-the-rise
Champ on-the-rise
Finally I got what I was looking for.
model.groups = groups.searchGroups("*");
This snippet is not elegant at all, but at least this works.