Programmierus/ldap-mailcow

Second sync fails

zeroone82 opened this issue · 4 comments

I've been trying to get this working and I have been able to get an initial sync at least. It will add my one test user, but then it fails on the second sync:

mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Config file conf/dovecot/ldap/passdb.conf unchanged
mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Config file conf/dovecot/extra.conf unchanged
mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Config file conf/sogo/plist_ldap unchanged
mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Added Mailcow user: testuser@mydomain.local (Active: True)
mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Activated testuser@mydomain.local in filedb
mailcowcustomized_ldap-mailcow | 25.09.20 16:37:50 Sync finished, sleeping 15 seconds before next cycle
mailcowcustomized_ldap-mailcow | Traceback (most recent call last):
mailcowcustomized_ldap-mailcow |   File "syncer.py", line 181, in <module>
mailcowcustomized_ldap-mailcow |     main()
mailcowcustomized_ldap-mailcow |   File "syncer.py", line 31, in main
mailcowcustomized_ldap-mailcow |     sync()
mailcowcustomized_ldap-mailcow |   File "syncer.py", line 54, in sync
mailcowcustomized_ldap-mailcow |     (api_user_exists, api_user_active, api_name) = api.check_user(email)
mailcowcustomized_ldap-mailcow |   File "/api.py", line 66, in check_user
mailcowcustomized_ldap-mailcow |     if 'active_int' not in rsp and rsp['type'] == 'error':
mailcowcustomized_ldap-mailcow | KeyError: 'type'
mailcowcustomized_ldap-mailcow exited with code 1

This a very basic user, has a username, first and last name and nothing else. Should I add another field too?

My docker-composer setup is:

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=ldap://my.ad.IP
          - LDAP-MAILCOW_LDAP_BASE_DN=OU=TestMail,DC=mydomain,DC=local
          - LDAP-MAILCOW_LDAP_BIND_DN=CN=Administrador,CN=Users,DC=mydomain,DC=local
          - LDAP-MAILCOW_LDAP_BIND_DN_PASSWORD=mypassword
          - LDAP-MAILCOW_API_HOST=http://mailcow.localip
          - LDAP-MAILCOW_API_KEY=MY-MAILCOW-KEY
          - LDAP-MAILCOW_SYNC_INTERVAL=15

So I'm no python developer, but I did some debugging. It seems to check for a json field "type: error" (I'm guessing mailcow would return this in some cases?).
But when I make a request for the added mailbox, it returns everything but there is no "type" field.

Mailcow had some API related updates on August 7, I'm guessing maybe that's related?

For reference, this is what an API request returns with /api/v1/get/mailbox/testuser@mydomain.local

    "max_new_quota": 107374182400,
    "username": "testuser@mydomain.local",
    "rl": false,
    "rl_scope": "domain",
    "is_relayed": 0,
    "name": "Test User",
    "last_imap_login": "1601058677",
    "last_smtp_login": "0",
    "last_pop3_login": "0",
    "active": 1,
    "domain": "mydomain.local",
    "local_part": "testuser",
    "quota": 0,
    "attributes": {
        "force_pw_update": "0",
        "tls_enforce_in": "0",
        "tls_enforce_out": "0",
        "sogo_access": "1",
        "imap_access": "1",
        "pop3_access": "1",
        "smtp_access": "1",
        "mailbox_format": "maildir:",
        "quarantine_notification": "hourly"
    },
    "quota_used": 0,
    "percent_in_use": "- ",
    "messages": 0,
    "spam_aliases": 0,
    "pushover_active": 0,
    "percent_class": "info"

I fixed it! I was slightly off. you just need to replace de field "active_int" with "active" in api.py. I'm using a custom api.py for now

@zeroone82
hey there.. As I'm not able to currently get this running (SoGo needs to be able to speak using ldaps instead of ldap for my setup to work for example..) , can you quickly share your modification so we know if my pull request is actually it..