Can't contact LDAP server #215

Closed
opened 2026-02-04 17:43:31 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @bsunderhus on GitHub (Dec 2, 2016).

PHP Version: 7.0-apache

MySQL Version: 5.712

Expected Behavior: LDAP connection

Actual Behavior: ldap_bind(): Unable to bind to server: Can't contact LDAP server

I'm using the solidnerd docker image but I don't think that there's any problem with the image, since all it does is pass the values.

Here's the docker-compose.yml file that pass the LDAP configuration to the bookstack

version: '2'
services:

  mysql:
    image: mysql:5.7.12
    environment:
    - MYSQL_ROOT_PASSWORD=secret
    - MYSQL_DATABASE=bookstack
    - MYSQL_USER=bookstack
    - MYSQL_PASSWORD=secret
    volumes:
    - ./mysql:/var/lib/mysql

  bookstack:
    image: solidnerd/bookstack:0.13.0
    depends_on:
    - mysql
    environment:
    - DB_HOST=mysql:3306
    - DB_DATABASE=bookstack
    - DB_USERNAME=bookstack
    - DB_PASSWORD=secret
    - APP_DEBUG=true
    - AUTH_METHOD=ldap
    - LDAP_SERVER=srp3.conexops.com.br:389
    - LDAP_DN="CN=Admin,CN=Users,DC=conexops,DC=com,DC=br"
    - LDAP_PASS=!#!@#@#
    - LDAP_BASE_DN=CN=Users,DC=conexops,DC=com,DC=br
    volumes:
    - ./uploads:/var/www/BookStack/public/uploads
    ports:
    - "3000:80"

I keep getting this error

ErrorException in Ldap.php line 94: ldap_bind(): Unable to bind to server: Can't contact LDAP server

in Ldap.php line 94
at HandleExceptions->handleError('2', 'ldap_bind(): Unable to bind to server: Can't contact LDAP server', '/var/www/BookStack/app/Services/Ldap.php', '94', array('ldapConnection' => resource, 'bindRdn' => 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', 'bindPassword' => '!@#@!#'))
at ldap_bind(resource, 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', '@!#@!#@#') in Ldap.php line 94
at Ldap->bind(resource, 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', '!#@!#!@#') in LdapService.php line 94
at LdapService->bindSystemUser(resource) in LdapService.php line 39
at LdapService->getUserDetails('user') in LdapUserProvider.php line 104
at LdapUserProvider->retrieveByCredentials(array('username' => 'user', 'password' => 'password')) in compiled.php line 617
at SessionGuard->attempt(array('username' => 'user', 'password' => 'password'), false) in compiled.php line 2517
at LoginController->login(object(Request))
at call_user_func_array(array(object(LoginController), 'login'), array(object(Request))) in compiled.php line 9385
at Controller->callAction('login', array(object(Request))) in compiled.php line 9412
at ControllerDispatcher->dispatch(object(Route), object(LoginController), 'login') in compiled.php line 8470
at Route->runController() in compiled.php line 8451
at Route->run(object(Request)) in compiled.php line 8147
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Controller.php line 44
at Controller->BookStack\Http\Controllers\{closure}(object(Request), object(Closure)) in compiled.php line 9862
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9978
at SubstituteBindings->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3151
at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13464
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 11907
at StartSession->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13210
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13147
at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9855
at Pipeline->then(object(Closure)) in compiled.php line 8148
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8139
at Router->dispatchToRoute(object(Request)) in compiled.php line 8130
at Router->dispatch(object(Request)) in compiled.php line 2472
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3213
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 9870
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9855
at Pipeline->then(object(Closure)) in compiled.php line 2416
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2400
at Kernel->handle(object(Request)) in index.php line 53

though I already tested the connection via ldapsearch -x -h srp3.conexops.com.br -p 389 -D "CN=Admin,CN=Users,DC=conexops,DC=com,DC=br" -b "CN=Users,DC=conexops,DC=com,DC=br" -w !@!$!@!# -d8 and it works just fine.

What am I doing wrong?

Originally created by @bsunderhus on GitHub (Dec 2, 2016). PHP Version: 7.0-apache MySQL Version: 5.712 Expected Behavior: LDAP connection Actual Behavior: ldap_bind(): Unable to bind to server: Can't contact LDAP server I'm using the [solidnerd docker image](https://github.com/solidnerd/docker-bookstack) but I don't think that there's any problem with the image, since all it does is pass the values. Here's the `docker-compose.yml` file that pass the LDAP configuration to the bookstack ```yml version: '2' services: mysql: image: mysql:5.7.12 environment: - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=bookstack - MYSQL_USER=bookstack - MYSQL_PASSWORD=secret volumes: - ./mysql:/var/lib/mysql bookstack: image: solidnerd/bookstack:0.13.0 depends_on: - mysql environment: - DB_HOST=mysql:3306 - DB_DATABASE=bookstack - DB_USERNAME=bookstack - DB_PASSWORD=secret - APP_DEBUG=true - AUTH_METHOD=ldap - LDAP_SERVER=srp3.conexops.com.br:389 - LDAP_DN="CN=Admin,CN=Users,DC=conexops,DC=com,DC=br" - LDAP_PASS=!#!@#@# - LDAP_BASE_DN=CN=Users,DC=conexops,DC=com,DC=br volumes: - ./uploads:/var/www/BookStack/public/uploads ports: - "3000:80" ``` I keep getting this error > ErrorException in Ldap.php line 94: ldap_bind(): Unable to bind to server: Can't contact LDAP server ``` in Ldap.php line 94 at HandleExceptions->handleError('2', 'ldap_bind(): Unable to bind to server: Can't contact LDAP server', '/var/www/BookStack/app/Services/Ldap.php', '94', array('ldapConnection' => resource, 'bindRdn' => 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', 'bindPassword' => '!@#@!#')) at ldap_bind(resource, 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', '@!#@!#@#') in Ldap.php line 94 at Ldap->bind(resource, 'CN=Isaac Pereira,CN=Users,DC=conexops,DC=com,DC=br', '!#@!#!@#') in LdapService.php line 94 at LdapService->bindSystemUser(resource) in LdapService.php line 39 at LdapService->getUserDetails('user') in LdapUserProvider.php line 104 at LdapUserProvider->retrieveByCredentials(array('username' => 'user', 'password' => 'password')) in compiled.php line 617 at SessionGuard->attempt(array('username' => 'user', 'password' => 'password'), false) in compiled.php line 2517 at LoginController->login(object(Request)) at call_user_func_array(array(object(LoginController), 'login'), array(object(Request))) in compiled.php line 9385 at Controller->callAction('login', array(object(Request))) in compiled.php line 9412 at ControllerDispatcher->dispatch(object(Route), object(LoginController), 'login') in compiled.php line 8470 at Route->runController() in compiled.php line 8451 at Route->run(object(Request)) in compiled.php line 8147 at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Controller.php line 44 at Controller->BookStack\Http\Controllers\{closure}(object(Request), object(Closure)) in compiled.php line 9862 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9978 at SubstituteBindings->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3151 at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13464 at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 11907 at StartSession->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13210 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13147 at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9855 at Pipeline->then(object(Closure)) in compiled.php line 8148 at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8139 at Router->dispatchToRoute(object(Request)) in compiled.php line 8130 at Router->dispatch(object(Request)) in compiled.php line 2472 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51 at Debugbar->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3213 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 9870 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9855 at Pipeline->then(object(Closure)) in compiled.php line 2416 at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2400 at Kernel->handle(object(Request)) in index.php line 53 ``` though I already tested the connection via `ldapsearch -x -h srp3.conexops.com.br -p 389 -D "CN=Admin,CN=Users,DC=conexops,DC=com,DC=br" -b "CN=Users,DC=conexops,DC=com,DC=br" -w !@!$!@!# -d8` and it works just fine. What am I doing wrong?
OVERLORD added the 🐛 Bug label 2026-02-04 17:43:31 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 3, 2016):

Hi @BernardoS,
Done a little test of this last night.

One thing I noted when using LDAP via docker is that I could not use my local LDAP server as the docker container is technically not on the same local network so double check if that could be the issue.

When I set up an external LDAP server I did find the docker-based instance worked differently to my local dev BookStack instance. It seemed to work but could not find a user when logging in even though the same ldap details were used for both instances.

I'll have to have a deeper dig at somepoint soon.

@ssddanbrown commented on GitHub (Dec 3, 2016): Hi @BernardoS, Done a little test of this last night. One thing I noted when using LDAP via docker is that I could not use my local LDAP server as the docker container is technically not on the same local network so double check if that could be the issue. When I set up an external LDAP server I did find the docker-based instance worked differently to my local dev BookStack instance. It seemed to work but could not find a user when logging in even though the same ldap details were used for both instances. I'll have to have a deeper dig at somepoint soon.
Author
Owner

@bsunderhus commented on GitHub (Dec 5, 2016):

Hey @ssddanbrown,

No I'm not using a local LDAP server.
All I can confirm is that the LDAP server is working fine (Bookstack is not the only one I'm using to access it) and is populated.

By the error msg I can just assume that the bookstack can't find my LDAP server, though it seems a little odd to me that the error happens in the authentication. Perhaps what you're saying of not being able to find a user when logging in is the reason.

@bsunderhus commented on GitHub (Dec 5, 2016): Hey @ssddanbrown, No I'm not using a local LDAP server. All I can confirm is that the LDAP server is working fine (Bookstack is not the only one I'm using to access it) and is populated. By the error msg I can just assume that the bookstack can't find my LDAP server, though it seems a little odd to me that the error happens in the authentication. Perhaps what you're saying of not being able to find a user when logging in is the reason.
Author
Owner

@turbotankist commented on GitHub (Sep 15, 2017):

@BernardoS
I has the same error without option "LDAP_USER_FILTER=(&(uid=${user}))"
Try to put it in your env

@turbotankist commented on GitHub (Sep 15, 2017): @BernardoS I has the same error without option "LDAP_USER_FILTER=(&(uid=${user}))" Try to put it in your env
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#215