# Failed to authenticate user with ldap realm using role mapping api

**URL:** https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [October 26, 2020, 10:00am UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285 "2020-10-26T10:00:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lusynda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lusynda/32/53557_2.png) [@lusynda](https://discuss.elastic.co/u/lusynda)
#### Post date: [October 26, 2020, 10:00am UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/1 "2020-10-26T10:00:49Z")

</div>

Hi all,  
Currently i have successfully tried to authen to elastic with ldap, but i used the role\_mapping file, i was tesing with using the role mapping api but it is not working.  
When i turn on the authen debug log then when ever i authen i get this log:

```auto
Authentication of [admin] using realm [ldap/ldap1] with token [UsernamePasswordToken] was [AuthenticationResult{status=CONTINUE, user=null, message=null, exception=null}]

```

The api call i tried was:

```auto
POST /_security/role_mapping/test
{
  "roles" : ["superuser"],
  "rules" : { "any" : [
      { "field" : { "dn" : "CN=admin,OU=IT,DC=ABC,DC=COM" } }
  ] },
  "enabled": true
}

```

Can some one point out to me what when wrong.  
One note is that on the ldap realm i config the server to authen with sAMAccountName, i dont know if that is the problems.

---

<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: [October 29, 2020, 4:37am UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/2 "2020-10-29T04:37:27Z")

</div>

That log message indicates that your LDAP realm is not authenticating the user. That means that this problem has nothing to do with role mapping, and is almost certainly a configuration problem in your LDAP realm.

You should turn on trace logging for the LDAP realm:

```auto
PUT _cluster/settings
{
  "transient": {
    "logger.org.elasticsearch.xpack.security.authc.ldap": "TRACE"
  }
}

```

---

<div class="post-metadata">

### Author: ![lusynda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lusynda/32/53557_2.png) [@lusynda](https://discuss.elastic.co/u/lusynda)
#### Post date: [October 29, 2020, 4:53am UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/3 "2020-10-29T04:53:46Z")

</div>

The config i have for the role\_mapping.yml file works for the authenticate so i dont thinks there is a problems with the config of ldap

---

<div class="post-metadata">

### Author: ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)
#### Post date: [October 29, 2020, 8:48am UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/4 "2020-10-29T08:48:08Z")

</div>

I second Tim's comment. Please do what we suggest, we only try to assist you here but you need to be willing to work with us.

---

<div class="post-metadata">

### Author: ![lusynda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lusynda/32/53557_2.png) [@lusynda](https://discuss.elastic.co/u/lusynda)
#### Post date: [October 30, 2020, 12:05pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/5 "2020-10-30T12:05:36Z")

</div>

I am so sorry i have figure out the problems, the search user in the config file and the dn in the api are not the same so it cannot authenticate, but now that i have change the dn of the api, it works now  
So thanks for your help.

---

<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: [November 27, 2020, 12:05pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-user-with-ldap-realm-using-role-mapping-api/253285/6 "2020-11-27T12:05:41Z")

</div>

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