LDAP Sync Error: User Deactivated Due to "Email Already Used" Validation Error

Zammad version: 6.5.0
Installation method: Package
Operating system: Ubuntu server
Database: PostgreSQL

Note: Email addresses and usernames are masked for privacy reasons.

Expected Behavior
LDAP synchronization should successfully sync user accounts from Active Directory to Zammad without validation errors.

Actual Behavior
During LDAP sync, one specific user account fails to synchronize and gets deactivated with the following error:

log text
E, [2025-10-14T11:02:32.673879#3686711-196180] ERROR – : Validation failed: Email address '***@***is already used for another user. (ActiveRecord::RecordInvalid)
The error repeats during each LDAP sync cycle.

Steps to Reproduce
Configure LDAP integration with Active Directory
Create/have a user in AD
Run LDAP synchronization
User fails to sync with ā€œEmail address is already used for another userā€ error
User account becomes deactivated

What I’ve Already Tried

  1. :white_check_mark: Searched the database for duplicates with ***@*** — none found
  2. :white_check_mark: Searched via web interface (active and inactive users) — none found
  3. :white_check_mark: Verified the AD mail attribute — correctly formatted with @
  4. :white_check_mark: Checked LDAP mapping configuration — appears correct

Questions

  1. Why does Zammad report ā€œEmail address is already used for another userā€ when no duplicate exists?
  2. Could this be related to orphaned records in the external_sync table or soft-deleted users?
  3. What SQL queries or Rails console commands can I run to fully detect any email conflicts?
  4. How can I resolve this issue—should I merge or delete duplicates, adjust uniqueness settings, or take another approach?

Related Community Topics
I found similar issues reported:

However, none of these describe the exact scenario where no duplicate can be found in the database or UI.

Additional Information

The production.log shows this error on every sync cycle. The AD user attributes are valid, but Zammad refuses to sync the account, claiming an email conflict that cannot be found.

Any guidance on troubleshooting or resolving this would be greatly appreciated!

Log Excerpt
text:
I, [2025-10-14T11:02:32.538276#3686711-196180] INFO – : Skipping. No Role assignment found for login ***
E, [2025-10-14T11:02:32.673879#3686711-196180] ERROR – : Validation failed: Email address ā€˜@’ is already used for another user. (ActiveRecord::RecordInvalid)
I, [2025-10-14T11:05:31.056163#3686711-196180] INFO – : LDAP job end

If I’d had to bet, I’d say that the user in question was created by a different LDAP server before (even if it was deleted after).

I believe I told you several times, or I mistake you with someone else:
Do never ever execute SQL queries, especially none that change data in Zammads database.
This can break existing functionality and even cause data loss.

Use the rails console. Executing ExternalSync.last will give you an idea of how the data structure looks like. As I’m out for a while on this topic, I neither have a LDAP absend instance to play with, nor do I remember the exact structure in that case.

1 Like

Thanks for the reply.

  1. This user was created on the same LPAD server as other users who successfully performed synchronization using ldap integration.
  2. We don’t use SQL queries to update data