# Kibana active directory

**URL:** https://discuss.elastic.co/t/kibana-active-directory/304917
**Category:** Kibana
**Tags:** elastic-stack-security
**Created:** [May 17, 2022, 10:12am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917 "2022-05-17T10:12:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Dmitrymig](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dmitrymig](https://discuss.elastic.co/u/Dmitrymig)
#### Post date: [May 17, 2022, 10:12am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/1 "2022-05-17T10:12:30Z")

</div>

Guys help me, I can't log in kibana, error 401, my settings are in Elasticsearch

```auto
xpack.security.enabled: true
xpack:
  security:
    authc:
      realms:
        active_directory:
          my_ad:
            domain_name: mgc.local
            url: ldap://mck-dc1.mgc.local:389
            bind_dn: CN=s-kibn,OU=SERVERS-MONITORING,OU=DC,DC=mgc,DC=local
            bind_password: 123456
            files.role_mapping: /etc/elasticsearch/role_mappings.yml

```

My Role Mapping Settings

```auto
superuser:
- cn=kibana-superuser,ou=Groups,ou=DC,dc=mgc,dc=local
- cn=DDenisov,ou=Users,ou=MIGCRDIT,dc=mgc,dc=local
user:
- "cn=kibana-users,cn=Groups,cn=DC,dc=mgc,dc=local"

```

I do curl -k -u DDenisov@domain:pass'[http://10.102.59.41:9200/\_xpack/security/\_authenticate?pretty](http://10.102.59.41:9200/_xpack/security/_authenticate?pretty)'

and get the correct answer

```auto
{
  "username" : "DDenisov@domain",
  "roles" : [
    "monitoring_user",
    "superuser"
  ],

```

I also created two rules for the mapping role in Kibana, one of them is monitoring\_user and it is displayed correctly, but when I try to log in under an account in Kibana, I get an error 401  
I don't know what to do now, please help

```auto
{"statusCode":401,"error":"Unauthorized","message":"[security_exception] unable to authenticate user [DDenisov@domain] for REST request [/_security/_authenticate], with { header={ WWW-Authenticate=\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\" } }"}

```

---

<div class="post-metadata">

### Author: ![Dzmitry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dzmitry/32/65026_2.png) [@Dzmitry](https://discuss.elastic.co/u/Dzmitry)
#### Post date: [May 17, 2022, 3:57pm UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/2 "2022-05-17T15:57:03Z")

</div>

Hi @Dmitrymig

What stack version are you using?

Did you check our [official docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/active-directory-realm.html) about AD authorisation?

Best, Dzmitry

---

<div class="post-metadata">

### Author: ![Dmitrymig](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dmitrymig](https://discuss.elastic.co/u/Dmitrymig)
#### Post date: [May 19, 2022, 7:44am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/3 "2022-05-19T07:44:56Z")

</div>

I am using version 7.9. I followed the documentation with the exception of "bind\_password:" I put it in Elasticsearch.yml and I configured the mapping role without the API but through the file. Elasticsearch shows the correct roles for the user, but when I try to enter Kibana via the WEB, an error 401 appears, I can’t find a solution on the Internet, so I contacted you)

---

<div class="post-metadata">

### Author: ![Dmitrymig](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dmitrymig](https://discuss.elastic.co/u/Dmitrymig)
#### Post date: [May 19, 2022, 12:49pm UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/4 "2022-05-19T12:49:19Z")

</div>

I get this response when I log in to Kibana and see a 401 error

[2022-05-19T15:45:29,491][DEBUG][o.e.x.s.a.AuthenticationService] [gray-1] Authentication of [s-kibana@mgc.local] using realm [active\_directory/my\_ad] with token [UsernamePasswordToken] was [AuthenticationResult{status=SUCCESS, user=User[username=s-kibana@mgc.local,roles=[monitoring\_user,superuser],fullName=null,email=null,metadata=

---

<div class="post-metadata">

### Author: ![Dmitrymig](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dmitrymig](https://discuss.elastic.co/u/Dmitrymig)
#### Post date: [May 19, 2022, 1:09pm UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/5 "2022-05-19T13:09:40Z")

</div>

Here's more from the log, how to resolve I don't understand

[2022-05-19T16:04:08,816][DEBUG][o.e.x.s.a.l.ActiveDirectorySessionFactory] [gray-1] Resolved 0 meta-data fields [{}] for user [

---

<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: [May 20, 2022, 4:46am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/6 "2022-05-20T04:46:54Z")

</div>

If you're seeing those messages, then authentication is working fine.

What's the exact error you see in Kibana? What does the kibana log tell you?

---

<div class="post-metadata">

### Author: ![Dmitrymig](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dmitrymig](https://discuss.elastic.co/u/Dmitrymig)
#### Post date: [May 20, 2022, 9:14am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/7 "2022-05-20T09:14:02Z")

</div>

sorry to distract you, I didn't set up the roles and didn't attach them to the role mapping  
Everything is working now

---

<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: [June 17, 2022, 9:14am UTC](https://discuss.elastic.co/t/kibana-active-directory/304917/8 "2022-06-17T09:14:57Z")

</div>

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