Programmierus/ldap-mailcow

syncer.py: TypeError: list indices must be integers or slices, not str

theoneandonly-vector opened this issue · 9 comments

docker-compose logs --tail=10 -f ldap-mailcow

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 52, in sync
mailcowcustomized_ldap-mailcow |     for (email, ldap_name, ldap_active) in ldap_results:
mailcowcustomized_ldap-mailcow |   File "//syncer.py", line 46, in <lambda>
mailcowcustomized_ldap-mailcow |     x[1]['userPrincipalName'][0].decode(),
mailcowcustomized_ldap-mailcow | TypeError: list indices must be integers or slices, not str

my "userPrincipalName":
looks like this:

surname.name@DOMAIN.TLD

maybe this was different because of the version of python used back when the image was built. but as I had to trust my CA-certificate I had to build it myself which leads to an updated system.

I just built it with:
"python:3.6-alpine3.13"
-> same error
"python:3.6-alpine3.12"
-> same

Widmo commented

I have the same error. Does anyone solved this issue?

@Widmo
just use this project:
https://github.com/myOmikron/mailcow-ldap-sync

it works perfectly for me.

Widmo commented

Thank You, I will try, but I'm afraid there is no any even simple documentation :)))

have a look at the issues.

paz commented

is there more information on this issue? are you using a windows server or linux ldap backend?

Widmo commented

Windows LDAP backend, this error appears even, when group / OU is empty.

Hi. I've added exception handler in syncer.py to ignore such errors. Try it.
PS. In my syncer.py instead of userPrincipalName I use mail attribute. If it is a problem for you just edit syncer.py (in lines 44 and 47)