# Link Consumer to LDAP authenticated API

**URL:** <https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352>\
**Category:** Questions\
**Created:** [January 9, 2018, 9:04am UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352 "2018-01-09T09:04:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![otrsw](https://avatars.discourse-cdn.com/v4/letter/o/46a35a/32.png) [@otrsw](https://discuss.konghq.com/u/otrsw)\
**Post date:** [January 9, 2018, 9:04am UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352/1 "2018-01-09T09:04:44Z")

</div>

Hi there.

I would like to link a consumer to an API that is authenticated with LDAP. Not sure if I am going about this the wrong way - but I would have expected to see LDAP as one of the Auth options when I edit a Consumer, but I cant.

How should I do this?

PS: So I have successfully configured the LDAP plugin and it works fine - but I would need to “link” the username (X-Credential-Username) header to a defined Consumer so I can add additional info and authorization settings

---

<div class="post-metadata">

**Author:** ![jpk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/jpk/32/127_2.png) [@jpk](https://discuss.konghq.com/u/jpk)\
**Post date:** [January 9, 2018, 9:43pm UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352/2 "2018-01-09T21:43:45Z")

</div>

Hi otrsw-

The LDAP plugin can’t be applied only to a certain consumer. It can only be applied globally, or on a specific API.

Can you please clarify what you mean by

> “link” the username (X-Credential-Username) header to a defined Consumer"

Thanks

---

<div class="post-metadata">

**Author:** ![otrsw](https://avatars.discourse-cdn.com/v4/letter/o/46a35a/32.png) [@otrsw](https://discuss.konghq.com/u/otrsw)\
**Post date:** [January 10, 2018, 9:51am UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352/3 "2018-01-10T09:51:59Z")

</div>

Hi there

Thanx for the feedback. Let me use an example:

Lets say there is a global ldap account for entity ABC

I want to define a consumer ABC in kong as well and that consumer info and properties should be passed on in the header to the downstream APIs. Specifically i want to add a JWT token defined for ABC in kong

Heinz Seldte  
ONTHEROCK Software  
0716043605  
[heinz@otrsw.com](mailto:heinz@otrsw.com)[mailto:heinz@otrsw.com](mailto:heinz@otrsw.com)

[X]

---

<div class="post-metadata">

**Author:** ![jpk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/jpk/32/127_2.png) [@jpk](https://discuss.konghq.com/u/jpk)\
**Post date:** [January 10, 2018, 6:34pm UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352/4 "2018-01-10T18:34:29Z")

</div>

Cool, thanks for the aditional info.

I don’t believe that would be possible with just the LDAP plugin alone (still need to do some testing before I can say that with confidence), but could you add in the [Response Transformer](https://getkong.org/plugins/response-transformer/?_ga=2.137558832.1019963217.1515425801-988888510.1508171677) plugin to add those fields in?

---

<div class="post-metadata">

**Author:** ![Robert\_Metcalf](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/robert_metcalf/32/150_2.png) [@Robert\_Metcalf](https://discuss.konghq.com/u/Robert_Metcalf)\
**Post date:** [January 19, 2018, 11:38am UTC](https://discuss.konghq.com/t/link-consumer-to-ldap-authenticated-api/352/5 "2018-01-19T11:38:06Z")

</div>

I am considering implementing the same process.  
I am thinking I need to design a login server accessed as an API in Kong. The login service would be protected by Kong LDAP plugin. When a request successfully gets to the login server it would use the Kong admin API to check if the consumer exists and create it if necessary. It would also add a JWT credential to the consumer and return this to the client. That way the client can use the JWT credential to access other API’s.

I still have to find out how the JWT token expiry process will work. I think my clients will need to re-login. Not sure if Kong JWT tokens have expiry.

I also need to research to find out if this functionality is already built into Kong. (If not it would be nice to have)
