Assign organisation to all users


  • Used Zammad version: 4.1.x
  • Used Zammad installation type: Package
  • Operating system: Ubuntu 18.04
  • Browser + version: Chrome, Brave

Expected behavior:

  • After OTRS import and user login via O365 they should get assigned to the organisation (domain based) automatically

Actual behavior:

  • After OTRS import and user login via O365 the organisation (domain based) is not assigned automatically. Is there a way to set the organisation for all users in bulk?

Steps to reproduce the behavior:

  • Import from OTRS, login using O365, organisation is not assigned

Please ensure that the organization in question is available and configured before the user in question is being created. Please also note that domain based assignment is taken in account only during the initial account creation.

This should also affect office365 logins without issue.

There’s no built in functionality to run the assignment in bulk.
The following rails script can do the trick.

Run at your own risk, have a backup to be sure and without any warranty.

Enforce new domain based assignment after user creation
# get organizations with domain based assignment and do magic to all users not having an organization yet
Organization.where(domain_assignment:true).pluck(:id).each{ |orgid|
  list += "Checking Organization: #{} (#{org.domain}) \n"
  next if org.domain == nil

  User.where(organization_id:nil).where("email LIKE '%@#{org.domain}'").pluck(:id).each { |user|
    list+= "... Found user (and upgraded to member): #{User.find(user).firstname} #{User.find(user).lastname} (#{User.find(user).email}) \n"
    User.find(user).update!(organization_id: orgid)
puts list
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.