Bulk upload users in group

cancel
Showing results for 
Search instead for 
Did you mean: 
Balaji123
Member II

Bulk upload users in group

Hi,

I want to add a number of users in a group. 

Let'us say i have 200 users in alfresco, so i want to add first 100 users in one group and another 100 users in an another group. how should i achive this.

please guide me.

3 Replies
abhinavmishra14
Advanced

Re: Bulk upload users in group

I am not sure if there is a way to achieve this OOTB. However, you can create a javascript or java backed webscript and do this easily. 

Here is an example of java backed webcript process:

You can pass the list of users and GroupId (e.g. GROUP_XYZGROUP) to the webscript and iterate each userId and get the person NodeRef using PersonService (org.alfresco.service.cmr.security.PersonService):

NodeRef personRef = personService.getPerson(userId);

You can use AuthorityDAO (org.alfresco.repo.security.authority.AuthorityDAO)service to get the groupNodeRef based on groupId you passed:

NodeRef groupNodeRef = authorityDAO.getAuthorityNodeRefOrNull(groupId);

Once you get groupNodeRef, call below given method (sample method, you can create your own if needed) and pass the group Noderef and person nodeRef to it. You would need NodeService and AuthorityService for this call.

 

 

 
private void addUserToGroup(NodeRef groupNodeRef,
	NodeRef personRef, NodeService nodeService,
	AuthorityService authorityService) {
	if (nodeService.getType(groupNodeRef).equals(ContentModel.TYPE_AUTHORITY_CONTAINER)) {
		String parentGroupName = (String) nodeService.getProperties(groupNodeRef).get(ContentModel.PROP_AUTHORITY_NAME);
		String authorityName = StringUtils.EMPTY;
		if (nodeService.getType(personRef).equals(ContentModel.TYPE_AUTHORITY_CONTAINER)){
			authorityName = (String) nodeService.getProperties(personRef).get(ContentModel.PROP_AUTHORITY_NAME);
		} else{
			authorityName = (String) nodeService.getProperties(personRef).get(ContentModel.PROP_USERNAME);
		}
		authorityService.addAuthority(parentGroupName, authorityName);
	}
}
 

 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
jljwoznica
Senior Member

Re: Bulk upload users in group

Please check this link which explains how to do this via a CSV file.

jpotts
Professional

Re: Bulk upload users in group

Definitely can do this with code as others have suggested, but I thought I'd give you some additional food for thought...

You might consider using an LDAP directory to manage your users and groups. Then you can do such things easily using the directory management tools associated with whatever directory you are using, and Alfresco will happily sync everything over.

The side-benefit, of course, is that other applications in your enterprise can also benefit from having a centralized directory. Plus, it is a lot easier to delegate administration of users and groups using an LDAP directory than it is with Alfresco natively.