# Error using LDAP/Active directory authentication

**URL:** <https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054>\
**Category:** Security\
**Created:** [October 29, 2020, 9:59am UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054 "2020-10-29T09:59:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergiospa](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sergiospa](https://forum.opensearch.org/u/sergiospa)\
**Post date:** [October 29, 2020, 9:59am UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/1 "2020-10-29T09:59:05Z")

</div>

Hello community,

I am trying to configure LDAP/Active directory authentication and it seems like it works well and it doesn’t at the same time. After I have done all the configuration, I try to log in Kibana using my LDAP credentials and it recognizes if the credentials are good or bad. But, if I successfully log in, I am asked for credentials again in a new window that pops up, it’s like a second layer of authentication that I don’t want:

 ![imagen](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/5621a5c3d0262a6b3a00faa3be1b570cc1c7c262.png)

And after using the same credentials here, I finally get an error:  
 ![imagen](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/74cab1bdb5f3142fd4a5a35af9d459f47b535ef8.png)

I have checked that I can list all indices using my LDAP credentials using the Elasticsearch API:  
` curl -k -u user:password https://ES-IP:9200/_cat/indices`

Checking the browser’s dev tools, I see that I get the error when I am forwarded to the page:  
`https://KIBANA-DNS/app/select_tenant?nextURL=%2F`

My Kibana service is using the admin user, and my LDAP backend role is being mapped to the role `all_access` and to another role with unlimited privileges and all permissions for the global and admin tenant.

When I log in Kibana, I can see this log in the Elasticsearch logs:

 ![imagen](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/3485f837c6ef8a59ab92ab60035cc68bbbac8794.png)

But after I get access denied when I put my credentials in the window that pops up (I don’t even know why I get asked credentials twice) I get this error in Kibana logs:

> Oct 29 13:14:06 kibana[12899]: {“type”:“response”,“@timestamp”:“2020-10-29T12:14:06Z”,“tags”:,“pid”:12899,“method”:“get”,“statusCode”:401,“req”:{“url”:“/app/select\_tenant?nextUrl=%2F”,“method”:“get”,“headers”:{“host”:“DNS”,“user-agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0”,“accept”:“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8”,“accept-language”:“fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3”,“accept-encoding”:“gzip, deflate, br”,“referer”:“[https://DNS/app/login?nextUrl=%2F",“upgrade-insecure-requests”:“1”,“x-forwarded-for”:“IP”,“connection”:“close”},“remoteAddress”:“IP”,“userAgent”:“IP”,“referer”:“https://DNS/app/login?nextUrl=%2F”},“res”:{“statusCode”:401,“responseTime”:29,“contentLength”:9},“message”:"GET](https://DNS/app/login?nextUrl=%2F%22,%22upgrade-insecure-requests%22:%221%22,%22x-forwarded-for%22:%22IP%22,%22connection%22:%22close%22%7D,%22remoteAddress%22:%22IP%22,%22userAgent%22:%22IP%22,%22referer%22:%22https://DNS/app/login?nextUrl=%2F%22%7D,%22res%22:%7B%22statusCode%22:401,%22responseTime%22:29,%22contentLength%22:9%7D,%22message%22:%22GET) /app/select\_tenant?nextUrl=%2F 401 29ms - 9.0B”}

So the questions are:

- Why do I have to put credentials twice?
- Why is my LDAP account not workig on the second authentication? If I use `admin:admin` or `kibanaserver:kibanaserver` there, it works.

Any ideas would be much appreciated.

Thank you.  
Regards,  
Sergio.

---

<div class="post-metadata">

**Author:** ![oscark](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/oscark/32/866_2.png) [@oscark](https://forum.opensearch.org/u/oscark)\
**Post date:** [October 30, 2020, 9:34am UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/2 "2020-10-30T09:34:35Z")

</div>

It sounds like your user does not have permission to use Kibana/ not having permission to use indexes required for using Kibana.

So when you log into Kibana you get authenticated with LDAP but your users does not have a role that gives it permission to use Kibana. You should be able to verify this hypothesis by giving your user more permissions, the predefined role kibana\_user should be enough. [Users and Roles - Open Distro Documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/security/access-control/users-roles/)

---

<div class="post-metadata">

**Author:** ![sergiospa](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sergiospa](https://forum.opensearch.org/u/sergiospa)\
**Post date:** [October 30, 2020, 2:04pm UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/3 "2020-10-30T14:04:46Z")

</div>

Hi oscark,

My LDAP group is mapped as a backend role to the roles `all_access` and to another one that has `unlimited` permissions on the index pattern `.kibana*` and all my data indices. Also, it has all privileges for the global and admin tenant.  
Thanks for your suggestion, I will try to map it to the `kibana_user` role too and let you know the result.  
Regards,  
Sergio.

---

<div class="post-metadata">

**Author:** ![sergiospa](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sergiospa](https://forum.opensearch.org/u/sergiospa)\
**Post date:** [November 3, 2020, 10:22am UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/4 "2020-11-03T10:22:36Z")

</div>

Hi,  
I have created a new test user and mapped it to the role `all_access`, and I can log in successfully using this user. However, my LDAP user keeps getting the Unauthorized access even if in the Elasticsearch logs it appears that the login was successful and the LDAP group is mapped via backend role to the `all_access` role too.

Any help would be appreciated.

Regards,  
Sergio.

---

<div class="post-metadata">

**Author:** ![sergiospa](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sergiospa](https://forum.opensearch.org/u/sergiospa)\
**Post date:** [November 9, 2020, 2:14pm UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/5 "2020-11-09T14:14:43Z")

</div>

Just an update. I have verified that if I change `enable_ssl` to false and change the port to 389, it works perfectly. If I enable SSL and change the port to 636, I have the error mentioned above.

---

<div class="post-metadata">

**Author:** ![Anthony](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/anthony/32/9939_2.png) [@Anthony](https://forum.opensearch.org/u/Anthony)\
**Post date:** [February 18, 2021, 2:42pm UTC](https://forum.opensearch.org/t/error-using-ldap-active-directory-authentication/4054/6 "2021-02-18T14:42:56Z")

</div>

@sergiospa the CA cert that was used to sign the certificate received from ldap needs to be included in the config as it tries to validate it. There is an option under config "  
pemtrustedcas\_filepath: /full/path/to/trusted\_cas.pem" where the ca cert should be specified. Can you provide your config.yml file?
