Duplicate Users (LDAP) Cant delete


  • Used Zammad version: 3.1.x
  • Used Zammad installation source: package
  • Operating system: debian
  • Browser + version: Firefox

Expected behavior:

  • Only one user per account

Actual behavior:

  • Two users with the same information

Steps to reproduce the behavior:

  • Make a user then add information to AD directory.

Basically I connected Zammad to our active directory server. I have found that its hard to delete information from zammad for better or worse.

I managed to delete all the test tickets via the console with no real issue.

I later added information to the active directory DB to include the email address for a user. This created a duplicate user.
I ran User.with_permissions(‘ticket.customer’).where(‘id NOT IN (SELECT customer_id FROM tickets)’).each(&:destroy) to try and purge all users. It purged some of them but I got this error

lid (Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (zammad.users, CONSTRAINT fk_rails_355a7ffe95 FOREIGN KEY (updated_by_id) REFERENCES users (id)): DELETE FROM users WHERE users.id = 40)

I just need to be able to delete users and tickets preferable from the browser but at least from simple command in the console.


The documentation holds help for deleting users.
Please note that you need to remove ticket data as well, as tickets can’t exist without their customer.


yes but its not very clear.
How am i supposed to run all of those commands one after another on the console. Why cant I just delete select the user name and run delete or purge.

In the end I have redone the database from zero. The instructions on how to redo the database are also not clear.

There is no reason why I should just be able to select X user from Y and Purge. Ask for confirmation if needed

Umm… sorry… but… copy + paste?
These are two code blocks.

Technically you could also copy and paste line by line if you’d really want to, because that’s what the rails console is capable of.

You can’t just delete a user, because your data is not in the right state to do so.
Clear text: You have references from other objects on the user object that block you from deleting.

This is a normal database mechanism (foreign keys) to protect the data to stay consistent. Besides it wouldn’t make sense to delete only half of the relevant data, especially in cases of GPRD.

It’s documented here:

It’s kinda hidden, because it usually is not necessary on package installations.

If the above is not good or clear enough, pull request to enhance the documentation are always welcome.

There is no UI for this yet, so imho impossible to select something.

yea i have copy the documentation and made changes to my local corporate wiki. I’d be happy to send it back upstream.

the bigger question is why did adding an email in active directory create duplicate users

Very good question indeed.

If I understand correctly, you had User X without mail address that has been synced from your active directory to Zammad.

Then, later on, you added a mail address to User X, correct?
Did the Zammad user X, by any chance, have a different mail address? This could have happened by manual work of an agent.

Right now I suspect we’re talking about a Microsoft onPremise Active Directory somewhat between 2008 and 201x. :slight_smile:

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