# How to use regex in role\_mapping.yml

**URL:** <https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241>\
**Category:** Elasticsearch\
**Created:** [April 2, 2020, 3:33pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241 "2020-04-02T15:33:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spadhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spadhi/32/45258_2.png) [@spadhi](https://discuss.elastic.co/u/spadhi)\
**Post date:** [April 2, 2020, 3:33pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241/1 "2020-04-02T15:33:20Z")

</div>

I am using below Role mapping configuration in role\_mapping.yml and it works.

kibana\_user:  
`- "CN=grp1_viewer,OU=Groups,OU=ISO,DC=abcd,DC=com"`  
`- "CN=grp1_editor,OU=Groups,OU=ISO,DC=abcd,DC=com"`  
`- "CN=grp1_admin,OU=Groups,OU=ISO,DC=abcd,DC=com"`

However can I use regex for CN like CN=grp1\_\* .  
I tried various combination, but it does not work.  
Appreciate a quick help.

---

<div class="post-metadata">

**Author:** ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)\
**Post date:** [April 3, 2020, 6:20am UTC](https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241/2 "2020-04-03T06:20:03Z")

</div>

I don't think role mapping file supports regex. Quote from the doc

> Please note however, that the role\_mappings.yml file is provided as a minimal administrative function and is not intended to cover and be used to define roles for all use cases.

For defining complex role mappings, please consult with the [role mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html).

---

<div class="post-metadata">

**Author:** ![spadhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spadhi/32/45258_2.png) [@spadhi](https://discuss.elastic.co/u/spadhi)\
**Post date:** [April 6, 2020, 12:25pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241/3 "2020-04-06T12:25:30Z")

</div>

thanks it helped

---

<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:** [May 4, 2020, 12:35pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-role-mapping-yml/226241/4 "2020-05-04T12:35:57Z")

</div>

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