cancel
Showing results for 
Search instead for 
Did you mean: 

How to add all users to group EMAIL_CONTRIBUTORS?

mpeters
Champ in-the-making
Champ in-the-making
Hi,

what would be the easiest way to add all Alfresco users to the group EMAIL_CONTRIBUTORS (or any other group)? Unfortunately it is not possible to add the group EVERYONE to another group like EMAIL_CONTRIBUTORS (or did I overlooked the obvious solution)? Certainly one could add  user by user to the targeted group, but doing this with a few hundred (dayly changing) users is quite annoying Smiley Surprised.

Any hints, please?

Kind regards
Markus
23 REPLIES 23

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi mpeters,

You can write a javascript  to add users to group.
Get all the users using query :

1  .  you can fire a lucene query to get all users for e.g.  QNAME:"usr:user"  or  use a javascript api  : Array getMembers(ScriptNode group)
2  . You can apply a for loop to get the user one by one and add in a group using another query :addAuthority(ScriptNode parentGroup, ScriptNode authority)

Thanks,

mpeters
Champ in-the-making
Champ in-the-making
Hello Amita,

thanks very much for your answer. That shouldn't be too difficult to implement.

Now I wonder about the best way to trigger the execution of such a script. Certainly one could start the script by defining an appropriate rule to execute the script or by calling the script via URL. But due to the fact, that we are doing a regular scheduled LDAP sync I would prefer to call the script right afterward the LDAP sync (so newly imported users can immediately added to the targeted group).

Is there a way to execute the javascript right after (or very close to) the LDAP sync?

Kind regards
Markus

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi mpeters ,

If that is the case you should write a scheduler which will run in  a time interval and  will execute a  business logic written in java class.
So there you can add code similar to  the one I suggest for a java script.You can check AuthorityService Interface for fetching users and adding to a group.
Users can be fetch using  : getContainedAuthorities(AuthorityType type, String name, boolean immediate)
add users to group using  :  addAuthority(String groupName,
                            userName);
Thanks,

mrogers
Star Contributor
Star Contributor
It should be possible to add EVERYONE to EMAIL_CONTRIBUTORS.   If it doesn't work then please make sure its raised in JIRA.

mpeters
Champ in-the-making
Champ in-the-making
It should be possible to add EVERYONE to EMAIL_CONTRIBUTORS.   If it doesn't work then please make sure its raised in JIRA.

Thanks for your response. I tried to ad EVERYONE to EMAIL_CONTRIBUTORS within Alfresco Share, but EVERYONE doesn't appear in the "Add Group" dialog (unlike other groups).

I actually opened a ticket regarding this problem, which responded in "It's not possible to add EVERYONE as a subgroup".

But if you can confirm, that it is possible to add EVERYONE to EMAIL_CONTRIBUTORS I would be happy to hear from you, so I could reopen the ticket (or raise it in JIRA).

Kind regards,
Markus

mrogers
Star Contributor
Star Contributor
Thanks for your responses.   I found a couple of issues that were fixed and validated in 3.4 Last September.    And in addition there is a work-around for this problem which is to use Alfresco Explorer.   What version are you testing on?

mpeters
Champ in-the-making
Champ in-the-making
Hi mpeters ,

If that is the case you should write a scheduler which will run in  a time interval and  will execute a  business logic written in java class.

Hello Amita,

thank you for your detailed answer. Well, what can I say? We are actually not involded with Alfresco so deep yet. Thus extending Alfresco with Java is not a solution at the moment I guess (shame on me).

I'm thinking about this easy solution: creating the javascript you recommended in your first response and then call it by a rule assigned to the "User Homes" space whenever an Object will be created, changed or deleted. So when the LDAP sync is executed and a new user is imported, then a new user space will be created and the rule triggers the script to be executed. Ok, if there are 5 new user, the script will run 5 times, but I tend to accept this "little" resource overusage.

Any comments regarding this idea?

Kind regards
Markus

mpeters
Champ in-the-making
Champ in-the-making
Thanks for your responses.   I found a couple of issues that were fixed and validated in 3.4 Last September.    And in addition there is a work-around for this problem which is to use Alfresco Explorer.   What version are you testing on?
We are using this configuration: Alfresco Enterprise 3.4.0 (168) 64bit, Windows 2008 Server 64bit, MS SQL 2008

I also tried to do this in Alfresco Explorer, but I couldn't even found a link (or button or menu item) to add a subgroup in the Groups Management form of the group EMAIL_CONTRIBUTORS. I can only add users or create a new group within EMAIL_CONTRIBUTORS (or any other group).

Kind regards
Markus

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi mpeters,
I'm thinking about this easy solution: creating the javascript you recommended in your first response and then call it by a rule assigned to the "User Homes" space whenever an Object will be created, changed or deleted. So when the LDAP sync is executed and a new user is imported, then a new user space will be created and the rule triggers the script to be executed. Ok, if there are 5 new user, the script will run 5 times, but I tend to accept this "little" resource overusage.

This should be fine if you  have no issue  in resource overusage.

Thanks,