# Remove all users from DB

**URL:** <https://forums.rocket.chat/t/remove-all-users-from-db/7178>\
**Category:** Community Support\
**Created:** [June 2, 2020, 7:31pm UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178 "2020-06-02T19:31:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![larry.brown](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@larry.brown](https://forums.rocket.chat/u/larry.brown)\
**Post date:** [June 2, 2020, 7:31pm UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/1 "2020-06-02T19:31:14Z")

</div>

I need to deleted all users from the db. I had my ldap base set wrong and imported all groups, computers, and users.  
I would like to drop all and resync with the correct base

### Server Setup Information

- Version of Rocket.Chat Server: 2.4.11
- Operating System: Ubuntu 18.04
- Deployment Method: Snap
- Number of Running Instances: 1
- DB Replicaset Oplog:
- NodeJS Version: 8.17.0
- MongoDB Version: 3.6.14
- Proxy: none
- Firewalls involved: none

---

<div class="post-metadata">

**Author:** ![phuber](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@phuber](https://forums.rocket.chat/u/phuber)\
**Post date:** [June 3, 2020, 5:39am UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/2 "2020-06-03T05:39:58Z")

</div>

I found this somewhre in the Internet and used this often…  
bash: mongo

use rocketchat  
db.users.remove({“ldap”: true});

---

<div class="post-metadata">

**Author:** ![larry.brown](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@larry.brown](https://forums.rocket.chat/u/larry.brown)\
**Post date:** [June 3, 2020, 11:12am UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/3 "2020-06-03T11:12:49Z")

</div>

Thank you very much. unfortunately, I found that and tried it.  
I get the following message: WriteResult ({“nRemoved” : 0 })  
and the users still exist

---

<div class="post-metadata">

**Author:** ![phuber](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@phuber](https://forums.rocket.chat/u/phuber)\
**Post date:** [June 3, 2020, 11:33am UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/4 "2020-06-03T11:33:39Z")

</div>

Hm, and the user are imported via LDAP? I have had no problems with this command. In this case I can not help you, I do not know the database structure nor mongodb commands.

---

<div class="post-metadata">

**Author:** ![larry.brown](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@larry.brown](https://forums.rocket.chat/u/larry.brown)\
**Post date:** [June 3, 2020, 11:45am UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/5 "2020-06-03T11:45:44Z")

</div>

Yes sir. That is correct they were syncd to active directory.  
Unfortunately, I do not know mongodb commands either.  
I tried to look at a tutorial but didn’t make much head way  
with it. Makes me miss mysql.

---

<div class="post-metadata">

**Author:** ![larry.brown](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@larry.brown](https://forums.rocket.chat/u/larry.brown)\
**Post date:** [June 3, 2020, 12:02pm UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/6 "2020-06-03T12:02:34Z")

</div>

I figured it out.  
I had to do the following  
use parties  
db.users.remove({“ldap”:true});

using the parties collection was the key for me

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![denzero13](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@denzero13](https://forums.rocket.chat/u/denzero13)\
**Post date:** [May 21, 2021, 9:49am UTC](https://forums.rocket.chat/t/remove-all-users-from-db/7178/7 "2021-05-21T09:49:55Z")

</div>

The comand have error db.users.remove ({“ldap”: true}); corect version db.users.remove ({“ldap”: true});
