# Can't delete User

**URL:** https://community.zammad.org/t/cant-delete-user/12535
**Category:** Technical assistance
**Created:** [October 31, 2023, 11:55am UTC](https://community.zammad.org/t/cant-delete-user/12535 "2023-10-31T11:55:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nadine1](https://community.zammad.org/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nadine1](https://community.zammad.org/u/nadine1)
#### Post date: [October 31, 2023, 11:55am UTC](https://community.zammad.org/t/cant-delete-user/12535/1 "2023-10-31T11:55:57Z")

</div>

### Infos:

- Used Zammad version: This is Zammad version 5.0.x
- Used Zammad installation type: docker-compose (self-hosted)
- Operating system:
- Browser + version: Chrome Version 118.0.5993.88 (Official Build) (x86\_64)

### Expected behavior:

- User gets deleted - all tickets set to base user

### Actual behavior:

- Deletion process fails with following error:

```auto
failed (ERROR: #<ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: update or delete on table "users" violates foreign key constraint "fk_rails_ab5f91f9d0" on table "mentions" DETAIL: Key (id)=(1833) is still referenced from table "mentions". >)

```

Unfortunately, I can’t upgrade the Zammad Version at the moment - I know it is already a bit outdated. I could edit the entries (102) in the mentions table manually, would just need to know if I should delete all entries for this user there or if I update the created\_by\_id column to the base user.

My initial. problem was that the user is always set back to active once the ldap has synced. I tried everything from changing the group assignment (which determines the agent status) to change the role to customer etc.

Thanks for all the possible help here.  
Best,  
Nadine

---

<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 31, 2023, 12:21pm UTC](https://community.zammad.org/t/cant-delete-user/12535/2 "2023-10-31T12:21:34Z")

</div>

Upgrade your installation, this should be a bug that’s already fixed.

---

<div class="post-metadata">

### Author: ![nadine1](https://community.zammad.org/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nadine1](https://community.zammad.org/u/nadine1)
#### Post date: [October 31, 2023, 12:45pm UTC](https://community.zammad.org/t/cant-delete-user/12535/3 "2023-10-31T12:45:04Z")

</div>

Thank you - but what could I do in the meantime. This leads to a wave of spam emails due to a non-existing email address and I need a quickfix before I can take on the upgrade.

---

<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 31, 2023, 12:47pm UTC](https://community.zammad.org/t/cant-delete-user/12535/4 "2023-10-31T12:47:02Z")

</div>

Deleting users doesn’t solve issues with spam messages coming in.

---

<div class="post-metadata">

### Author: ![nadine1](https://community.zammad.org/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nadine1](https://community.zammad.org/u/nadine1)
#### Post date: [October 31, 2023, 12:59pm UTC](https://community.zammad.org/t/cant-delete-user/12535/5 "2023-10-31T12:59:14Z")

</div>

I think I didn’t phrase this clear enough. My zammad instance tries to reach this user - a former agent - (among others) via email. But this email-address does not exist anymore, and I’m flooded with exchange emails due to this. I can’t remove the Agent-Status (it is reset each time ldap syncs), I can’t inactivate the user permanently (same reason). Therefore, I thought the deletion would help…

---

<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 31, 2023, 1:03pm UTC](https://community.zammad.org/t/cant-delete-user/12535/6 "2023-10-31T13:03:45Z")

</div>

LDAP sync would synchronize it back in all the time.  
Fix your LDAP filter if the user account is no longer available in the result during sync it will be deactivated.

Or take over the user session and disable mail notifications.

See  
[https://admin-docs.zammad.org/en/latest/system/integrations/ldap/manage.html](https://admin-docs.zammad.org/en/latest/system/integrations/ldap/manage.html)  
and  
[https://admin-docs.zammad.org/en/latest/manage/users/via-the-admin-panel.html](https://admin-docs.zammad.org/en/latest/manage/users/via-the-admin-panel.html)  
and  
[https://user-docs.zammad.org/en/latest/extras/profile-and-settings.html](https://user-docs.zammad.org/en/latest/extras/profile-and-settings.html)

---

<div class="post-metadata">

### Author: ![nadine1](https://community.zammad.org/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nadine1](https://community.zammad.org/u/nadine1)
#### Post date: [October 31, 2023, 1:06pm UTC](https://community.zammad.org/t/cant-delete-user/12535/7 "2023-10-31T13:06:25Z")

</div>

Thank you a lot - will try your suggestions.

---

<div class="post-metadata">

### Author: ![nadine1](https://community.zammad.org/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nadine1](https://community.zammad.org/u/nadine1)
#### Post date: [November 7, 2023, 11:16am UTC](https://community.zammad.org/t/cant-delete-user/12535/8 "2023-11-07T11:16:28Z")

</div>

Thank you again for your support - just wanted to let you know that the hint regarding the ldap filters helped in my case. It turned out the ldap db was not updated. Thank you!

---

<div class="post-metadata">

### Author: ![system](https://community.zammad.org/uploads/default/original/1X/5c5afaea2d23f811dbec33cd4edb02fa29d3262f.png) [@system](https://community.zammad.org/u/system)
#### Post date: [November 14, 2023, 11:16am UTC](https://community.zammad.org/t/cant-delete-user/12535/9 "2023-11-14T11:16:55Z")

</div>

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