# I need help with group filter

**URL:** <https://forums.rocket.chat/t/i-need-help-with-group-filter/7456>\
**Category:** Community Support\
**Created:** [July 2, 2020, 4:48pm UTC](https://forums.rocket.chat/t/i-need-help-with-group-filter/7456 "2020-07-02T16:48:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WebGreg](https://avatars.discourse-cdn.com/v4/letter/w/f08c70/32.png) [@WebGreg](https://forums.rocket.chat/u/WebGreg)\
**Post date:** [July 2, 2020, 4:48pm UTC](https://forums.rocket.chat/t/i-need-help-with-group-filter/7456/1 "2020-07-02T16:48:49Z")

</div>

Hello

### Description

I just start with Rocket and I don’t know how to properly configure my filter to sync it with AD.

I have been using Spark until now. I had a group containing dozens of other groups from different containers, and my “Group Mapping” filter looked like this:  
_**(memberOf=CN=Spark\_groups,OU=Spark\_Groups,DC=domain,DC=com)**_  
Worked perfectly. Spark mapped all that groups with members. I could share them for users.

But now it doesn’t work. With this filter Rocket import all users and puts everyone in every mapped room. You know what I mean? Excample:  
_CN=department\_group,OU=technicians,OU=city1,DC=domain,DC=com_ \< 4 users as members  
_CN=seller\_group,OU=distribution,OU=city2,DC=domain,DC=com_ \< 5 members  
_CN=testers\_group,OU=implementation,OU=city3,DC=domain,DC=com_ \< 1 member  
All three groups are members of the group Spark\_groups. I map all three LDAP groups in Rocket Channel map. And what did I get?  
Channel Testers with 10 users,  
Channel Seller with 10 users,  
Channel Department with 10 users.  
In Spark:  
Channel Testers with 4 users,  
Channel Seller with 5 users,  
Channel Department with 1 users.

It works OK with:  
_**(&(sAMAccountName=#{username})(memberOf=CN=#{groupName},OU=technicians,OU=city1,DC=domain,DC=com))**_  
But only for this one group.

Is it possible to set some sensible filter that will catch all containers?  
Or do I have to copy group members to new groups in the same container and this is the only method? Example:  
_CN=CopyDepartment\_group,OU=RocketChat,DC=domain,DC=com_ \< 4 users as members  
_CN=CopySeller\_group,OU=RocketChat,DC=domain,DC=com_ \< 5 members  
_CN=CopyTesters\_group,OU=RocketChat,DC=domain,DC=com_ \< 1 member  
With filter:  
_**(&(sAMAccountName=#{username})(memberOf=CN=#{groupName},OU=RocketChat,DC=domain,DC=com))**_

### Server Setup Information

- Version of Rocket.Chat Server: 3.3.3
- Operating System: Ubuntu 20 LTS
- Number of Running Instances: 1
- NodeJS Version: v12.14.0
- MongoDB Version: 4.0.19

---

<div class="post-metadata">

**Author:** ![mitjam](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mitjam](https://forums.rocket.chat/u/mitjam)\
**Post date:** [July 6, 2020, 10:40am UTC](https://forums.rocket.chat/t/i-need-help-with-group-filter/7456/2 "2020-07-06T10:40:58Z")

</div>

What I did is:

1. (Rocket.Chat) **Base DN** : _OU=Users,DC=company,DC=com_

2. Then I created groups for Rocket.Chat in AD (or you can use other existing groups, if applicable):  
_OU=Chat,OU=Aplications,OU=Groups,DC=company,DC=com_

3. (Rocket.Chat) **User Group Filter** : _(&(sAMAccountName=#{username})(memberOf:1.2.840.113556.1.4.1941:=CN=#{groupName},OU=Chat,OU=Aplications,OU=Groups,DC=company,DC=com)(objectCategory=person)(objectClass=user))_

4. (Rocket.Chat) **LDAP Group BaseDN** : _OU=Users,DC=company,DC=com_

5. (Rocket.Chat) **LDAP Group Channel Map** :  
_{  
“Chat channel - employees”: “Company channel”,  
“Chat channel - Department 1”: “Department 1”,  
“Chat channel - Department 2”: “Department 2”  
“Chat channel - Department 3”: [“Department 3”,“Department 2”]  
}_

6. (Rocket.Chat) **User Search**

- **Filter** : _(&(objectCategory=person)(objectClass=user)(memberOf:1.2.840.113556.1.4.1941:=CN=Chat vsi,OU=Chat,OU=Aplikacije,OU=Skupine,DC=triglavre,DC=si)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))_  
Note: !(userAccountControl:1.2.840.113556.1.4.803:=2) ignores disabled users in AD. Or else disabled users from AD will appear too.

- **Search Field** : _sAMAccountName,mail_  
Note: You can ignore “mail” if you do not want that user can login with email address too.
