Project

General

Profile

Is it possible to automatically add new users to a group and/or project?

Added by Joseph Mulloy over 12 years ago

I have a Redmine server that authenticates users against Active Directory using the LDAP functionality in Redmine. When users login the first time a Redmine account is created for them. I'd like to automatically make new users a member of the project (we only have one) so that they can have more permissions than I can give to the "Non-Member" role, and so they can be added as watchers to Issues. So far I haven't been able to find away to either automatically add all new users to a project with a default role or add all new users to a group, which could then be added as a member of a project. Right now I have to check for non-members and add them. It's not hard but it's a manual process. If I can't do this natively in Redmine I'll write a Perl script to do it through the API. Of course the API doesn't have an easy method to figure out which users are not members of a project, so I'll have to do a good bit of parsing and processing.


Replies (9)

RE: Is it possible to automatically add new users to a group and/or project? - Added by Diana Savvatina over 12 years ago

Then maybe it would be easier to write a redmine plugin (or maybe there is already one which can do this).
A plugin could detect that a user is registered.
It would be good if a "default role" is configured for each project.
then a plugin would loop through projects and assign a configured "default role" for the enw user.
It would be very helpful especially if there are multiple projects.

It might be also useful to assign some default role to all existing registered users when a new project is created.

I'm very new to Redmine, so currently I can only dream about writing it :-)
But if you're going to spend some time on scripting, it would be better to do something which can be used by others and which can be easily extended even for grown needs of your company.

Good luck! :-)

RE: Is it possible to automatically add new users to a group and/or project? - Added by Arthur Zalevsky almost 11 years ago

Plugin of this kind is very easy to write. I've written this one which works for self-registered users in 15 minutes. And it can be easy extended for ldap users.

RE: Is it possible to automatically add new users to a group and/or project? - Added by Diana Savvatina almost 11 years ago

Thanks a lot!
It's a good start point for my question.

RE: Is it possible to automatically add new users to a group and/or project? - Added by Daniele Santoro almost 11 years ago

Arthur Zalevsky wrote:

Plugin of this kind is very easy to write. I've written this one which works for self-registered users in 15 minutes. And it can be easy extended for ldap users.

Hi, I'm installing your plugin on Redmine version 2.1.2.stable.10546 with Rails version 3.2.11 but it doesn't work. Can you let me know if I need to follow any particular installations steps or if it is compatible just with other Redmine versions ?

Thanks

RE: Is it possible to automatically add new users to a group and/or project? - Added by Arthur Zalevsky almost 11 years ago

Daniele Santoro wrote:

Arthur Zalevsky wrote:

Plugin of this kind is very easy to write. I've written this one which works for self-registered users in 15 minutes. And it can be easy extended for ldap users.

Hi, I'm installing your plugin on Redmine version 2.1.2.stable.10546 with Rails version 3.2.11 but it doesn't work. Can you let me know if I need to follow any particular installations steps or if it is compatible just with other Redmine versions ?

Thanks

Basically you have to perform db migration like with any other plugin.

rake redmine:plugins:migrate RAILS_ENV=production

After that existing group has to be set as default in the plugin menu.

Plugin works for self registered users, with "automatic activation" option set in global settings.

I didn't test it with any other installations except mine (I have 2.3.4.stable.12398 now).

Sorry for so many limitations but it was a kind of quick experiment. If this doesn't work let me know and I'll setup your version and try to do something to make it work.

RE: Is it possible to automatically add new users to a group and/or project? - Added by Franco Nogarin over 10 years ago

I have done all of the above and set the default group to

SPARCS Support Users

But new users still have no role.

my system:

Environment:
  Redmine version                2.5.0.stable.12982
  Ruby version                   2.0.0-p451 (2014-02-24) [x86_64-linux]
  Rails version                  3.2.17
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.6.17
  Git                            1.7.9.5
  Filesystem                     
Redmine plugins:
  redmine_announcements          1.0
  redmine_charts2                0.2.1
  redmine_code_review            0.6.3
  redmine_custom_css             0.1.4
  redmine_default_group          0.0.1
  redmine_issue_checklist        2.0.5
  redmine_login_audit            0.1.4
  redmine_my_page_queries        2.0.9
  redmine_open_links_in_new_window 0.0.3
  timelog_timer                  2.0.0

Any advice you can share on getting it working?
Thanks in advance
Franco

RE: Is it possible to automatically add new users to a group and/or project? - Added by Bahri Yardim about 10 years ago

Hi, i also needed this functionality. I had a little time to accomplish it, so i couldn't find time to write a plugin. However i achieved it by modifying a core file. Here's the solution:

File: redmine-2.5.1/apps/redmine/htdocs/app/models/users.rb
Line: 187
Before:

  if user.save
    user.reload
    logger.info("User '#{user.login}' created from external auth source: #{user.auth_source.type} - #{user.auth_source.name}") if logger && user.auth_source
  end

After:

  if user.save
    # Core Modification
    # Add User to Default Group (be sure to specify group id manually)
    group = Group.find(:first, :conditions => "id = 34")
    group.users << user
    user.reload
    logger.info("User '#{user.login}' created from external auth source: #{user.auth_source.type} - #{user.auth_source.name}") if logger && user.auth_source
  end

Hopefully, someone will find it useful.

RE: Is it possible to automatically add new users to a group and/or project? - Added by Victor Gershgorn about 10 years ago

Bahri, Many thanks for posting the code - it was extremely useful.

We are using Bitnami Stack with Redmine 2.5.2, and the file you posted did not exist - however it worked when added in
redmine/htdocs/app/controllers/account_controller.rb

If anyone is going to try and apply this in this file - note the following lines will probably need to be inserted under each of the user.save methods in this file (you can find them in the comments above the functions themselves):

   group = Group.find(:first, :conditions => "id = 34")
group.users << user

If you are wondering what is the group id for a specific group - you can find the number in the URL if you log into the redmine web UI with an admin account, and go to Administration->Groups->your_desired_group

It seems to work with users created and authenticated by mail - I have not tried additional scenarios.

Hope it will help somebody as well.

RE: Is it possible to automatically add new users to a group and/or project? - Added by Anonymous over 7 years ago

Redmine Plugin : Add LDAP Users to Group

I just made some plugin that could help people with Redmine ~3.2

Redmine plugin that automatically adds newly logged-in LDAP users to specific group that is configurated in plugin's settings.

https://github.com/savoirfairelinux/redmine-add-ldap-user-to-group

    (1-9/9)