Organization/User mapping

Yes there is.

However, I have to warn you:

  • create a backup
  • be aware that this is no official Zammad script
  • this script has been “slightly” tested and might react “odd” on big instances
  • we do not take any responsibility for wrong mapping, data loss, etc

Now to the fun part:

Magic to domain assign users if the organization has been created after user creation
# get organizations with domain based assignment and do magic to all users not having an organization yet
org=''
list=''
Organization.where(domain_assignment:true).pluck(:id).each{ |orgid|
  org=Organization.find(orgid)
  list += "Checking Organization: #{org.name} (#{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)
  }
  org=''
}
puts list