Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't contact LDAP server (-1) for user when using openldap #100

Open
Marketos-Damigos opened this issue Jul 31, 2022 · 7 comments
Open

Comments

@Marketos-Damigos
Copy link

I am getting this error message when I try to login to the server as in #29 :

Unable to connect to LDAP server openldap
Error: Can't contact LDAP server (-1) for user
Failed to Authenticate to server
Invalid Username or Password.

If i use ldapsearch inside the container, using either the env variable or directly specifying openldap:1389 it works perfectly.
I have the following docker-compose file:

  openldap:
    image: bitnami/openldap:2.6-debian-10
    container_name: openldap
    environment:
      PUID: 1000
      PGID: 1000
      LDAP_ALLOW_ANON_BINDING: no
      LDAP_ADMIN_USERNAME: admin
      LDAP_ADMIN_PASSWORD: 
      LDAP_CUSTOM_LDIF_DIR: /ldifs
      LDAP_ROOT: dc=example,dc=com
    restart: always
    networks:
      web:
        ipv4_address: 172.20.0.43
    ports:
      - 1389:1389    
    volumes:
      - ./containers/openldap/ldifs:/ldifs:ro
      - ./containers/openldap/ldap:/bitnami/openldap
    labels:
      - traefik.enable=true
      ## HTTP Routers
      - "traefik.http.routers.openldap-rtr.entrypoints=https"
      - "traefik.http.routers.openldap-rtr.rule=Host(`openldap.$DOMAINNAME_CLOUD_SERVER`)"
      - "traefik.http.routers.openldap-rtr.tls=true"
      ## Middlewares
      # - "traefik.http.routers.wiki-rtr.middlewares=middlewares-oauth@file"
      ## HTTP Services
      - "traefik.http.routers.openldap-rtr.service=openldap-svc"
      - "traefik.http.services.openldap-svc.loadbalancer.server.port=1389"
      - "com.centurylinklabs.watchtower.enable=true"


  phpldapadmin:
    image: osixia/phpldapadmin:latest
    container_name: phpldapadmin
    environment:
      PHPLDAPADMIN_LDAP_HOSTS: "openldap:1389"
      PHPLDAPADMIN_HTTPS: "false"
    ports:
      - "9214:80"
    command: --loglevel=debug
    depends_on:
      - openldap
    networks:
      web:
        ipv4_address: 172.20.0.45
    restart: always
@pplmx
Copy link

pplmx commented Apr 14, 2023

Hi, @Marketos-Damigos
Do you fix it finally? When I use bitnami/opneldap, I encounter the same issue. ><

@baba2k
Copy link

baba2k commented Apr 15, 2023

You have to set the port to 389 inside the container when using internal docker network. You can do that with

      - LDAP_PORT_NUMBER=389
      - LDAP_LDAPS_PORT_NUMBER=636

@pplmx
Copy link

pplmx commented Apr 15, 2023

Hi, @baba2k
Thanks for your comment. :)
It works fine.

@suityou01
Copy link

This is still a problem for me

services:
  ldap-server:
    image: osixia/openldap:1.5.0
    environment:
      - LDAP_ORGANISATION="My Co"
      - LDAP_DOMAIN="myco.co.uk"
      - LDAP_ADMIN_PASSWORD="fjfjsdf;sd"
      - LDAP_PORT_NUMBER=389
      - LDAP_LDAPS_PORT_NUMBER=636
  ldap-admin:
    depends_on:
      - ldap-server
    image: osixia/phpldapadmin:0.9.0
    environment:
      - PHPLDAPADMIN_LDAP_HOSTS=ldap-server
    ports:
      - 443:443
Unable to connect to LDAP server ldap
Error: Can't contact LDAP server (-1) for user

Please help

@suityou01
Copy link

Isn't this the osixia repo? Can I get help for osixia images here?

@suityou01
Copy link

Can I get some help with this please?

I checked that the docker container could resolve the host name. It could not. I added a docker network to the stack and specified container names (not that this has any bearing on name resolution, just pointing out what I have done differently)

I am able to submit an LDAP query in the LDAP container.
I am able to ping the LDAP container from the LDAP-ADMIN container.

The problem persists.

Latest compose file

services:
  ldap-server:
    container_name: ldap-server
    image: osixia/openldap:1.5.0
    environment:
      - LDAP_ORGANISATION=myco
      - LDAP_DOMAIN=myco.co.uk
      - LDAP_ADMIN_PASSWORD=itsasecret
      - LDAP_PORT_NUMBER=389
      - LDAP_LDAPS_PORT_NUMBER=636
    ports:
      - 636:636
      - 389:389
    networks:
      - ldap-network
  ldap-admin:
    container_name: ldap_admin
    depends_on:
      - ldap-server
    image: osixia/phpldapadmin:0.9.0
    environment:
      - PHPLDAPADMIN_LDAP_HOSTS=ldap-server
    ports:
      - 443:443
    networks:
      - ldap-network

networks:
  ldap-network:
    driver: bridge

@proxyflux
Copy link

@suityou01 just creating a new network solved the issue for me. For me the problem was that I was using the default network which doesn't have the dns_enabled. Were you able to solve it through some other way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants