LDAP over TLS: Unable to bind to server: Can't contact LDAP server #990

Closed
opened 2026-02-04 23:17:45 +03:00 by OVERLORD · 16 comments
Owner

Originally created by @Mant1kor on GitHub (Jan 15, 2019).

Describe the bug
Login via Active Directory account.
Sometimes I've got error: ldap_bind(): Unable to bind to server: Can't contact LDAP server

Screenshots
default
default

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v0.25.0 clean installation
  • PHP Version: PHP 7.2.14
  • Hosting Method (Nginx/Apache/Docker): nginx/1.12.2

Additional context
.env options

AUTH_METHOD=ldap

# LDAP authentication configuration
LDAP_SERVER=ldaps://dc.domain.com:636
LDAP_BASE_DN=DC=domain,DC=com
LDAP_DN=CN=LDAP,OU=AutoInstall,DC=domain,DC=com
LDAP_PASS=strong_password
LDAP_USER_FILTER=(&(sAMAccountName=${user}))
LDAP_VERSION=3
LDAP_TLS_INSECURE=true
LDAP_EMAIL_ATTRIBUTE=mail
LDAP_FOLLOW_REFERRALS=false

AD level: 2008 R2

Originally created by @Mant1kor on GitHub (Jan 15, 2019). **Describe the bug** Login via Active Directory account. **Sometimes** I've got error: `ldap_bind(): Unable to bind to server: Can't contact LDAP server` **Screenshots** ![default](https://user-images.githubusercontent.com/5281753/51171598-fa5e2100-18b9-11e9-96f1-abb806a04f06.png) ![default](https://user-images.githubusercontent.com/5281753/51172066-157d6080-18bb-11e9-81ee-fd3f74a36a90.png) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): v0.25.0 clean installation - PHP Version: PHP 7.2.14 - Hosting Method (Nginx/Apache/Docker): nginx/1.12.2 **Additional context** `.env` options ``` AUTH_METHOD=ldap # LDAP authentication configuration LDAP_SERVER=ldaps://dc.domain.com:636 LDAP_BASE_DN=DC=domain,DC=com LDAP_DN=CN=LDAP,OU=AutoInstall,DC=domain,DC=com LDAP_PASS=strong_password LDAP_USER_FILTER=(&(sAMAccountName=${user})) LDAP_VERSION=3 LDAP_TLS_INSECURE=true LDAP_EMAIL_ATTRIBUTE=mail LDAP_FOLLOW_REFERRALS=false ``` AD level: 2008 R2
OVERLORD added the 🐕 Support label 2026-02-04 23:17:45 +03:00
Author
Owner

@Mant1kor commented on GitHub (Jan 15, 2019):

Update: the issue reproduce only when connected to LDAP_SERVER over TLS
LDAP_SERVER=ldaps://dc.domain.com:636

@Mant1kor commented on GitHub (Jan 15, 2019): Update: the issue reproduce only when connected to LDAP_SERVER over TLS LDAP_SERVER=**ldaps**://dc.domain.com:636
Author
Owner

@ssddanbrown commented on GitHub (Jan 15, 2019):

Sorry to hear you're having issues @Mant1kor,
Just to confirm is this a new BookStack/Ldap setup you're experiencing this on or are you just experiencing this after performing an update?

Sometimes I've got error: ldap_bind(): Unable to bind to server: Can't contact LDAP server

Does this mean it sometimes does work as expected, without error?

@ssddanbrown commented on GitHub (Jan 15, 2019): Sorry to hear you're having issues @Mant1kor, Just to confirm is this a new BookStack/Ldap setup you're experiencing this on or are you just experiencing this after performing an update? > Sometimes I've got error: ldap_bind(): Unable to bind to server: Can't contact LDAP server Does this mean it sometimes does work as expected, without error?
Author
Owner

@Mant1kor commented on GitHub (Jan 15, 2019):

Just to confirm is this a new BookStack/Ldap setup you're experiencing this on or are you just experiencing this after performing an update?

It's a new BookStack/Ldap setup.

Does this mean it sometimes does work as expected, without error?

Yep, error occurs in ~50% of attempts. I'll try to record video proof.

@Mant1kor commented on GitHub (Jan 15, 2019): > Just to confirm is this a new BookStack/Ldap setup you're experiencing this on or are you just experiencing this after performing an update? It's a new BookStack/Ldap setup. > Does this mean it sometimes does work as expected, without error? Yep, error occurs in ~50% of attempts. I'll try to record video proof.
Author
Owner

@Mant1kor commented on GitHub (Jan 15, 2019):

Looks like that's solve my problem:
LDAP_USER_FILTER=(&(objectCategory=Person)(sAMAccountName=${user}))
Give me a ~day to check in detail.

@Mant1kor commented on GitHub (Jan 15, 2019): Looks like that's solve my problem: `LDAP_USER_FILTER=(&(objectCategory=Person)(sAMAccountName=${user}))` Give me a ~day to check in detail.
Author
Owner

@Mant1kor commented on GitHub (Jan 16, 2019):

@ssddanbrown still something wrong with ldap auth
gif_

@Mant1kor commented on GitHub (Jan 16, 2019): @ssddanbrown still something wrong with ldap auth ![gif_](https://user-images.githubusercontent.com/5281753/51248944-63b56100-199a-11e9-8e40-4fc0767aa8f7.gif)
Author
Owner

@ssddanbrown commented on GitHub (Jan 16, 2019):

This sounds very similar to #1069 and perhaps #247.

If I'm honest, I'm not really sure how to diagnose such an issue.

@ssddanbrown commented on GitHub (Jan 16, 2019): This sounds very similar to #1069 and perhaps #247. If I'm honest, I'm not really sure how to diagnose such an issue.
Author
Owner

@Mant1kor commented on GitHub (Jan 16, 2019):

I'm not a specialist, but some people(googled) recommends to use ldap_start_tls() instead of ldap_bind()
It's not critical, I'll use ldap:// to avoid the problem.
And I remind you again: the issue reproduce only with ldaps://

@Mant1kor commented on GitHub (Jan 16, 2019): I'm not a specialist, but some people(googled) recommends to use ldap_start_tls() instead of ldap_bind() It's not critical, I'll use ldap:// to avoid the problem. And I remind you again: the issue reproduce only with ldap**s**://
Author
Owner

@FreeTheTech101 commented on GitHub (Jan 17, 2019):

I personally believe there is something going wrong with verified LDAPS. Despite enabling trust my personal CA, I still encountered this issue. The "temporary" work around which I ended up using (which I cannot solely recommend) is changing the following lines:

LDAP_TLS_INSECURE=true

to

LDAPTLS_REQCERT=never

@FreeTheTech101 commented on GitHub (Jan 17, 2019): I personally believe there is something going wrong with verified LDAPS. Despite enabling trust my personal CA, I still encountered this issue. The "temporary" work around which I ended up using (which I cannot solely recommend) is changing the following lines: > LDAP_TLS_INSECURE=true to > LDAPTLS_REQCERT=never
Author
Owner

@cenix102 commented on GitHub (Jan 21, 2019):

Hello to everyone!

I have the same problem. Maybe my configuration is wrong or something else. (PS: I tried the configuration from this issue).

Config:
AUTH_METHOD=ldap

LDAP_SERVER=ldaps://172.25.60.10:636
LDAP_BASE_DN=dc=mydnname=com
LDAP_DN=uid=ldap.admin,cn=mygroup,ou=global,dc=amydcname,dc=com
LDAP_PASS=mypassword
LDAP_USER_FILTER=(&(objectCategory=Person)(sAMAccountName=${user}))
LDAP_VERSION=3
LDAP_EMAIL_ATTRIBUTE=mail
LDAP_TLS_INSECURE=never
APP_DEBUG=true
@cenix102 commented on GitHub (Jan 21, 2019): Hello to everyone! I have the same problem. Maybe my configuration is wrong or something else. (PS: I tried the configuration from this issue). Config: AUTH_METHOD=ldap ``` LDAP_SERVER=ldaps://172.25.60.10:636 LDAP_BASE_DN=dc=mydnname=com LDAP_DN=uid=ldap.admin,cn=mygroup,ou=global,dc=amydcname,dc=com LDAP_PASS=mypassword LDAP_USER_FILTER=(&(objectCategory=Person)(sAMAccountName=${user})) LDAP_VERSION=3 LDAP_EMAIL_ATTRIBUTE=mail LDAP_TLS_INSECURE=never APP_DEBUG=true ```
Author
Owner

@Mant1kor commented on GitHub (Jan 21, 2019):

@cenix102 use ldap:// to avoid the problem. And waiting for the fix...
LDAP_SERVER=ldap://172.25.60.10:389

And one more thing:

LDAP_DN=uid=ldap.admin,cn=mygroup,ou=global,dc=amydcname,dc=com

Using admin credentials is not necessary and secure. Use a normal user account.

@Mant1kor commented on GitHub (Jan 21, 2019): @cenix102 use ldap:// to avoid the problem. And waiting for the fix... `LDAP_SERVER=ldap://172.25.60.10:389` And one more thing: >LDAP_DN=uid=ldap.admin,cn=mygroup,ou=global,dc=amydcname,dc=com Using admin credentials is not necessary and secure. Use a normal user account.
Author
Owner

@cenix102 commented on GitHub (Jan 21, 2019):

@Mant1kor thanks for your answer. Now I have some credential errors...

PS: ldap.admin is just a the name. The user have not admin access. :-)

@cenix102 commented on GitHub (Jan 21, 2019): @Mant1kor thanks for your answer. Now I have some credential errors... PS: ldap.admin is just a the name. The user have not admin access. :-)
Author
Owner

@christophert commented on GitHub (Feb 6, 2019):

Setting LDAP_TLS_INSECURE is the equivalent TLS REQCERT never in /etc/ldap/ldap.conf for the session so this might be unrelated.

I personally haven't run in to this issue with our AD infrastructure (2012R2/2016). Are there any log entries in the DC's auth log that indicate authentication failure? What OS is BookStack running on?

@christophert commented on GitHub (Feb 6, 2019): Setting `LDAP_TLS_INSECURE` is the equivalent `TLS REQCERT never` in `/etc/ldap/ldap.conf` for the session so this might be unrelated. I personally haven't run in to this issue with our AD infrastructure (2012R2/2016). Are there any log entries in the DC's auth log that indicate authentication failure? What OS is BookStack running on?
Author
Owner

@Mant1kor commented on GitHub (Feb 7, 2019):

It's strange, but I can't reproduce the problem any more.
The difference is:

  • BookStack Version: v0.25.0 -> v0.25.1
  • AD forest level: 2008 -> 2008 R2

OS: CentOS 7

@Mant1kor commented on GitHub (Feb 7, 2019): It's strange, but I can't reproduce the problem any more. The difference is: * BookStack Version: v0.25.0 -> v0.25.1 * AD forest level: 2008 -> 2008 R2 OS: CentOS 7
Author
Owner

@Duan-fei commented on GitHub (Mar 12, 2019):

@Mant1kor
I also met this kind of problem, have you solved this problem,Can you help me?
This is my ldap configuration:
微信截图_20190312133125

@Duan-fei commented on GitHub (Mar 12, 2019): @Mant1kor I also met this kind of problem, have you solved this problem,Can you help me? This is my ldap configuration: ![微信截图_20190312133125](https://user-images.githubusercontent.com/31236990/54176865-611f4580-44cb-11e9-8615-dbb688a3a0fe.png)
Author
Owner

@Mant1kor commented on GitHub (Mar 14, 2019):

@Duan-fei
You don't use encryption. Did you get the same error "Can't contact LDAP server"?

@Mant1kor commented on GitHub (Mar 14, 2019): @Duan-fei You don't use encryption. Did you get the same error "Can't contact LDAP server"?
Author
Owner

@ssddanbrown commented on GitHub (May 18, 2019):

An issue was found in how BookStack handles LDAP URI's. A fix was applied for release v0.26: c24764018a

If anyone is still experiencing issues it's work updating to the latest release as you may find your issue has been fixed.

@ssddanbrown commented on GitHub (May 18, 2019): An issue was found in how BookStack handles LDAP URI's. A fix was applied for release v0.26: c24764018a9684fcf4418b359ddd793bb380063b If anyone is still experiencing issues it's work updating to the latest release as you may find your issue has been fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#990