osixia / docker-phpLDAPadmin

phpLDAPadmin container image 🐳🌴
MIT License
851 stars 197 forks source link

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

Open Marketos-Damigos opened 2 years ago

Marketos-Damigos commented 2 years ago

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 commented 1 year ago

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

baba2k commented 1 year ago

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 commented 1 year ago

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

suityou01 commented 4 months ago

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 commented 4 months ago

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

suityou01 commented 4 months ago

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