# Bulk User-delete 

**URL:** https://community.zammad.org/t/bulk-user-delete/21419
**Category:** Technical assistance
**Created:** [October 20, 2026, 6:21pm UTC](https://community.zammad.org/t/bulk-user-delete/21419 "2026-10-20T18:21:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Karsten](https://community.zammad.org/letter_avatar_proxy/v4/letter/k/e47c2d/32.png) [@Karsten](https://community.zammad.org/u/Karsten)
#### Post date: [October 20, 2026, 6:21pm UTC](https://community.zammad.org/t/bulk-user-delete/21419/1 "2026-10-20T18:21:59Z")

</div>

### Infos:

Hi, due to an error, we imported over 1,000 users from LDAP. These have since been deactivated following a fix to the LDAP configuration. We are now left with a large number of “stale” (deactivated) user accounts that are no longer needed. Is it possible to perform a bulk deletion using the criteria `active:false` and `source:ldap`?

- Used Zammad version: 7.2.1
- Used Zammad installation type: source
- Operating system: RockyOS 9 latest
- Browser + version: Edge, latest

### Expected behavior:

- -

### Actual behavior:

- -

### Steps to reproduce the behavior:

- -

---

<div class="post-metadata">

### Author: ![MrGeneration](https://community.zammad.org/user_avatar/community.zammad.org/mrgeneration/32/9260_2.png) [@MrGeneration](https://community.zammad.org/u/MrGeneration)
#### Post date: [October 20, 2026, 10:53pm UTC](https://community.zammad.org/t/bulk-user-delete/21419/2 "2026-10-20T22:53:50Z")

</div>

Yes, that’s technically possible. However, it won’t clean up sync references.

The following will delete all inactive users that came from LDAP source. It will also delete any tickets of affected customers, if applicable. Data loss, yada yada yada.

> **Dangerzone**
>
> The immediate way that deletes all users in one go:
> 
> ```ruby
> User.where(active: false).where('source LIKE ?', 'Ldap::%').find_in_batches do |batch|
> batch.each do |user|
> user.destroy!
> end
> end
> 
> ```
> 
> Not as immediate, adding them as Data Privacy task and let the background worker do it over time. Also easier on your system in general.
> 
> ```ruby
> UserInfo.current_user_id = 1
> 
> User.where(active: false).where('source LIKE ?', 'Ldap::%').find_in_batches do |batch|
> batch.each do |user|
> task = DataPrivacyTask.create(deletable: user)
> puts "#{user.id} #{user.login}: #{task.errors.full_messages.join(', ')}" if task.errors.any?
> end
> end
> 
> ```
