cancel
Showing results for 
Search instead for 
Did you mean: 

adding user/group into space

pamela
Champ in-the-making
Champ in-the-making
here's the situation:

I have to programmatically add a person into a group , but before i can add this user to this group, i have to create the group. The problem here is… the group should exist inside the created folder/space.

if you do this manually using the web client, your process should be like this:

*managing users inside the space
> select the folder
> click "more actions"
> select "manage space users"
> invite a group
etc.

*managing users via admin console
> the usual create group wizard


The question is, how can i do the creation of group and add it as people that can access the space i created (programmatically)?
3 REPLIES 3

zaizi
Champ in-the-making
Champ in-the-making
You can either add an existing group to the users or create a custom group to manage users just for that space. You can create the group when you create the space.

If you want to see code samples, check out the Alfresco source code and see how the Invite User Wizard and Create Space wizard code.

damiar
Champ in-the-making
Champ in-the-making
Should be something like this

var groupNode = people.getGroup("GROUP_" + name_of_the_group_the_user_must_belong_to);
if (groupNode == null) {
  groupNode = people.createGroup(name_of_the_group_the_user_must_belong_to);
  groupNode.save();
}

// 'person' is injected in the script by Alfresco.
people.addAuthority(groupNode, person);

var folderNode = companyhome.childByNamePath(path_to_user_folder);
folderNode.setPermission("Contributor", groupNode);

I suggest you to read: http://wiki.alfresco.com/wiki/3.1_JavaScript_API

Hope it helps.

prachi
Champ in-the-making
Champ in-the-making
Hi

Is there any rest api for creating users/groups/roles. In our project we need to create Users in Alfresco using Rest APIs.
Please let us know if anyone has worked on it.

Any pointers will be helpful.

Regards,
Prachi.