Programmierus / ldap-mailcow

LDAP account synchronization and authentication for mailcow-dockerized
95 stars 37 forks source link

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

Open theoneandonly-vector opened 3 years ago

theoneandonly-vector commented 3 years ago

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
theoneandonly-vector commented 3 years ago

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.

theoneandonly-vector commented 3 years ago

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

Widmo commented 3 years ago

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

theoneandonly-vector commented 3 years ago

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

it works perfectly for me.

Widmo commented 3 years ago

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

theoneandonly-vector commented 3 years ago

have a look at the issues.

paz commented 3 years ago

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

Widmo commented 3 years ago

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

drlight17 commented 2 years ago

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)