# Assigned roles \[create\_doc\] were not found) on indices

**URL:** <https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [March 15, 2024, 10:38am UTC](https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470 "2024-03-15T10:38:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kra28](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kra28](https://discuss.elastic.co/u/kra28)\
**Post date:** [March 15, 2024, 10:38am UTC](https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470/1 "2024-03-15T10:38:05Z")

</div>

Hello,  
I have some troubles to add a document into an index. Thank you for your answer.

I have created a user kra28 and index pdbs\_index and add the privileges using:

```auto
{
  "indices": [
    {
      "names": [
        "pdbs_index"
      ],
      "privileges": [
        "create_doc"
      ]
    }
  ]
}

```

When I check it, I get:  
`{"kra28":{"cluster":[],"indices":[{"names":["pdbs_index"],"privileges":["create_doc"],"allow_restricted_indices":false}],"applications":[],"run_as":[],"metadata":{},"transient_metadata":{"enabled":true}}}*`

However when I want to add a document using:  
`http://xyz:9200/pdbs_index/_doc/1`

I get the following issue:  
`{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:data/write/index] is unauthorized for user [kra28] with effective roles [] (assigned roles [create_doc] were not found) on indices [pdbs_index], this action is granted by the index privileges [create_doc,create,index,write,all]"}],"type":"security_exception","reason":"action [indices:data/write/index] is unauthorized for user [kra28] with effective roles [] (assigned roles [create_doc] were not found) on indices [pdbs_index], this action is granted by the index privileges [create_doc,create,index,write,all]"},"status":403}*`

It is not clear for me, since, it seems, that I have created the privileges.

Thank you for your answer.

Michal

---

<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:** [March 18, 2024, 5:20am UTC](https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470/2 "2024-03-18T05:20:36Z")

</div>

You seem to be mixing up users, roles and privileges.

This:

> `{"kra28":{"cluster":[],"indices":[{"names":["pdbs_index"],"privileges":["create_doc"],"allow_restricted_indices":false}],"applications":[],"run_as":[],"metadata":{},"transient_metadata":{"enabled":true}}}*`

Looks like the output from a role (`GET /_security/role/kra28`)

But this:

> `{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:data/write/index] is unauthorized for user [kra28]`

Is referring to a **user** named `kra28`

> `with effective roles [] (assigned roles [create_doc] were not found)`

And that user has been assigned a **role** named `create_doc`

It sounds like you need to update the configuration of user `kra28` to have the role named `kra28`.

---

<div class="post-metadata">

**Author:** ![kra28](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kra28](https://discuss.elastic.co/u/kra28)\
**Post date:** [March 19, 2024, 1:03pm UTC](https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470/3 "2024-03-19T13:03:44Z")

</div>

Thank you very much, it seems that it is correct now. I add the role "kra28" using:

`http://<url>/_security/user/kra28`

```auto
{
  "password": "xyz",
  "enabled": true,
  "roles": ["kra28"],
  "full_name" : "kra28",
  "email" : "..."
}

```

Add the role "write":

`http://<url>/_security/role/kra28`

```auto
{
  "indices": [
    {
      "names": [
        "pdbs_index"
      ],
      "privileges": [
        "create_doc", "write"
      ]
    }
  ]
}

```

A the result of the insert:  
`http://<url>/pdbs_index/_doc/1`  
is the following:  
`{"_index":"pdbs_index","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}*`

Thank you.

Regards,

Michal

---

<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:** [April 16, 2024, 1:03pm UTC](https://discuss.elastic.co/t/assigned-roles-create-doc-were-not-found-on-indices/355470/4 "2024-04-16T13:03:58Z")

</div>

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