Organization/User mapping

  • Used Zammad version: 3.1.0
  • Used Zammad installation source: DEB
  • Operating system: Debian/GNU Linux 9
  • Browser + version:

Hello,

I am synchronizing my users with LDAP.
The organization/domain-mapping is set.
However, users do not have an organization set.

When is the mapping done?
Could it be, because I created the Organizations AFTER initial LDAP-sync?

BR, Christian

Hi Christian,

I think this is a normal behavior as LDAP users are created different than those created via incoming email. Having the same thing going on in [several] one installation[s]…

Babak

EDIT:
I am stupid. Just checked that in one installation. Simply spelled the domain wrong. argl. now it seems to work…

Hi,

is there a way to update a users Organization via CLI somehow?
For example: Update Organization to “xxx” if mail-address contains “yyy.tld”?

BR, Christian

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

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