# How to combine (logical "and") membership of 2 LDAP groups in role\_mapping file

**URL:** <https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [February 22, 2021, 10:22pm UTC](https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133 "2021-02-22T22:22:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javad\_Alipanah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javad_alipanah/32/84353_2.png) [@Javad\_Alipanah](https://discuss.elastic.co/u/Javad_Alipanah)\
**Post date:** [February 22, 2021, 10:22pm UTC](https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133/1 "2021-02-22T22:22:50Z")

</div>

Hello everybody,  
I have trouble writing LDAP role\_mapping.yml.  
I want to map users who are members of both 'elk-users' and 'team-core' groups to an elastic role. I did it through API and Lucene language using the 'all' keyword but cannot translate it to YAML file.  
this is my role\_mapping file contents:

```auto
superuser:
  - cn=elk-admins,dc=yektanet,dc=tech
test_role:
  - cn=elk-users,cn=team-core,dc=yektanet,dc=tech

```

the superuser role mapping works well but the second mapping always fails (no roles for a user with both elk-users and team-core group membership).

I would be grateful if someone helps me through this.  
Thanks.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [February 23, 2021, 5:15am UTC](https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133/2 "2021-02-23T05:15:32Z")

</div>

It is not possible to do that in the role mapping file.  
If you need that functionality then you will need to use to role mapping API instead.

---

<div class="post-metadata">

**Author:** ![Javad\_Alipanah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javad_alipanah/32/84353_2.png) [@Javad\_Alipanah](https://discuss.elastic.co/u/Javad_Alipanah)\
**Post date:** [February 23, 2021, 2:33pm UTC](https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133/4 "2021-02-23T14:33:30Z")

</div>

Thanks for the answer.  
However, it's worth mentioning I did a workaround by putting my LDAP query in `user_search.filter` field:

```auto
user_search:
  base_dn: "dc=yektanet,dc=tech"
  filter: "(&(cn={0})(|(memberOf=cn=elk-users,dc=yektanet,dc=tech)(memberOf=cn=elk-admins,dc=yektanet,dc=tech)))"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 23, 2021, 2:34pm UTC](https://discuss.elastic.co/t/how-to-combine-logical-and-membership-of-2-ldap-groups-in-role-mapping-file/265133/5 "2021-03-23T14:34:10Z")

</div>

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