# LDAPAuthentication Error

**URL:** <https://discourse.jupyter.org/t/ldapauthentication-error/27965>\
**Category:** The Littlest JupyterHub\
**Tags:** help-wanted\
**Created:** [August 29, 2024, 6:47pm UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965 "2024-08-29T18:47:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LTJH](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@LTJH](https://discourse.jupyter.org/u/LTJH)\
**Post date:** [August 29, 2024, 6:47pm UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/1 "2024-08-29T18:47:25Z")

</div>

I have a fresh Debian image and trying to install TLJH. I copied my config file below. I set it with statements like `sudo tljh-config set auth.LDAPAuthenticator.server_address [REDACTED]`. When I try to log in with LDAP credentials, there is a 60 second timeout. I confirmed my credentials are correct with `ldapsearch` as well as other services. I also tried having an admin creating the user first and then signing in with LDAP credentials.

Is there an easier way to debug this type of an error without the 60 second timeout?

```auto
users:
  admin:
  - admin
auth:
  LDAPAuthenticator:
    server_address: [REDACTED]
    server_port: 389
    bind_dn_template: '["CN={username},OU=[REDACTED],DC=[REDACTED],DC=[REDACTED]"]'
    lookup_dn: false
    user_search_base: OU=[REDACTED],DC=[REDACTED],DC=[REDACTED]
    user_attribute: sAMAccountName
    lookup_dn_search_filter: ({login_attr}={login})
    lookup_dn_search_user: CN=[REDACTED],OU=[REDACTED],DC=[REDACTED],DC=[REDACTED]
    lookup_dn_search_password: [REDACTED]
    use_ssl: false

```

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [August 30, 2024, 9:30am UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/2 "2024-08-30T09:30:35Z")

</div>

Could you try with `bind_dn_template` without `[]`? Like `bind_dn_template: "CN={username},OU=[REDACTED],DC=[REDACTED],DC=[REDACTED]"`

---

<div class="post-metadata">

**Author:** ![LTJH](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@LTJH](https://discourse.jupyter.org/u/LTJH)\
**Post date:** [August 30, 2024, 1:56pm UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/3 "2024-08-30T13:56:46Z")

</div>

Thanks for the suggestion! Unfortunately, it didn’t work.

Do I need to have the user created by an admin before logging in for the first time? (For example, successfully logging into Apache Airflow with LDAP will create a new user in the database). If there is no user, I get an authentication error. If the user exists, I can successfully log in but with any password I type in.

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [September 1, 2024, 4:44pm UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/4 "2024-09-01T16:44:43Z")

</div>

Yes, `LDAPAuthenticator` will not create users in LDAP directory if not found. You should have the users created beforehand.

---

<div class="post-metadata">

**Author:** ![LTJH](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@LTJH](https://discourse.jupyter.org/u/LTJH)\
**Post date:** [September 4, 2024, 1:33pm UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/5 "2024-09-04T13:33:51Z")

</div>

Thank you. That makes sense but I am running into an issue where the admin creates the user but the user can log in with any password the first time, not just the LDAP password.

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [September 5, 2024, 6:32am UTC](https://discourse.jupyter.org/t/ldapauthentication-error/27965/6 "2024-09-05T06:32:05Z")

</div>

That sounds more like the issue with LDAP config. The authenticator itself attempts to make [a connection](https://github.com/jupyterhub/ldapauthenticator/blob/ba1e059315ccdac7e3ddfad30f27b496f520ddac/ldapauthenticator/ldapauthenticator.py#L303-L313) with the provided credentials. You can test it by using `ldapsearch` to make a bind for a newly created user with any password to make sure that the problem lies with LDAP server.
