Skip to content

Starting container fails with ldap.initialize(f"{config['LDAP_URI']}") #9

@Clevero

Description

@Clevero

Hello :)

I'm currently trying to install your LDAP integration and followed the install instructions.

After starting the container, the log states that ldap.initialize(f"{config['LDAP_URI']}") is throwing an error:

Aug 17 14:00:49 localhost f12f15c8c8bd[563]: 17.08.20 12:00:49 Config file conf/dovecot/ldap/passdb.conf unchanged
Aug 17 14:00:49 localhost f12f15c8c8bd[563]: 17.08.20 12:00:49 Config file conf/dovecot/extra.conf unchanged
Aug 17 14:00:49 localhost f12f15c8c8bd[563]: 17.08.20 12:00:49 Config file conf/sogo/plist_ldap unchanged
Aug 17 14:00:49 localhost f12f15c8c8bd[563]: Traceback (most recent call last):
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "syncer.py", line 181, in <module>
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     main()
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "syncer.py", line 31, in main
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     sync()
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "syncer.py", line 37, in sync
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     ldap_connector = ldap.initialize(f"{config['LDAP_URI']}")
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "/usr/local/lib/python3.8/site-packages/ldap/functions.py", line 94, in initialize
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     return LDAPObject(
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "/usr/local/lib/python3.8/site-packages/ldap/ldapobject.py", line 115, in __init__
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     self._l = ldap.functions._ldap_function_call(ldap._ldap_module_lock,_ldap.initialize,uri)
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:   File "/usr/local/lib/python3.8/site-packages/ldap/functions.py", line 55, in _ldap_function_call
Aug 17 14:00:49 localhost f12f15c8c8bd[563]:     result = func(*args,**kwargs)
Aug 17 14:00:49 localhost f12f15c8c8bd[563]: ldap.LDAPError: (0, 'Error')

My addition to docker-compose.override.yml:

  ldap-mailcow:
    image: programmierus/ldap-mailcow
    network_mode: host
    container_name: mailcowcustomized_ldap-mailcow
    depends_on:
        - nginx-mailcow
    volumes:
        - ./data/ldap:/db:rw
        - ./data/conf/dovecot:/conf/dovecot:rw
        - ./data/conf/sogo:/conf/sogo:rw
    environment:
        - LDAP-MAILCOW_LDAP_URI="ldaps://1.2.3.4"
        - LDAP-MAILCOW_LDAP_BASE_DN=OU=Firma,DC=OURCOMPANY,DC=LOCAL
        - LDAP-MAILCOW_LDAP_BIND_DN=CN=ldap,DC=OURCOMPANY,DC=LOCAL
        - LDAP-MAILCOW_LDAP_BIND_DN_PASSWORD=ChangeMe
        - LDAP-MAILCOW_API_HOST=https://5.6.7.8
        - LDAP-MAILCOW_API_KEY=My-Wonderful-API-Key-Hello
        - SYNC_INTERVAL=300

Steps I tried before opening the issue:

I checked the credentials and some other settings with ldapsearch and could successfully connect to the LDAP server:

root@mailcow-srv:/opt/mailcow-dockerized# ldapsearch -x -LLL -h 1.2.3.4 -D ldap@OURCOMPANY.LOCAL -W -b OU=Firma,DC=OURCOMPANY,DC=LOCAL dn
Enter LDAP Password:
dn: OU=Firma,DC=OURCOMPANY,DC=local

dn: CN=............,OU=Firma,DC=OURCOMPANY,DC=local

dn: CN=............,OU=Firma,DC=OURCOMPANY,DC=local

dn: CN=............,OU=Firma,DC=OURCOMPANY,DC=local

etc.

I also checked the connectivity to the LDAP server inside a debian based test container with network=host:

root@mailcow-srv:/opt/mailcow-dockerized# docker run --network=host -it debian /bin/bash
root@mailcow-srv:/# apt update && apt install netcat
.....
root@mailcow-srv:/# nc -vz 1.2.3.4 636
dc1.OURCOMPANY..local [1.2.3.4] 636 (?) open
root@mailcow-srv:/# nc -vz 1.2.3.4 389
dc1.OURCOMPANY..local [1.2.3.4] 389 (?) open
root@mailcow-srv:/#

After that, I tried to reproduce this behaviour in extra container with python3 and python-ldap installed. The wasn't thrown.

root@ldaptest:~# cat test.py 
import sys, os, string, time, datetime
import ldap


ldap_connector = ldap.initialize(f"ldaps://1.2.3.4")
root@ldaptest:~# python3 test.py 
root@ldaptest:~#

I hope you have some spare time to look through my issue with setting up the integration but totally understand that your support is limited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions