zabbix-tooling / zabbix-ldap-sync

Sync Zabbix with LDAP directory server
BSD 3-Clause "New" or "Revised" License
49 stars 35 forks source link

Unable to delete users from group if 'alldirusergroup' option isn't set. #55

Open CompPhy opened 1 year ago

CompPhy commented 1 year ago

We don't care about "audit" trail and left the alldirusergroup option out of our configuration. This causes an issue because there's a check against zabbix_alldirusergroup_users when looking for accounts to delete. In this case, it will never delete any users that no longer exist in the AD group. Which in turn causes other issues downsteam, for example then trying to do media sync.

Basically the error below is a downstream consequence, because the user doesn't exist in the LDAP group anymore but hasn't been removed prior to the media sync.

Traceback (most recent call last): File "/var/lib/zabbix/zabbix-ldap-sync/zabbix-ldap-sync", line 115, in main() File "/var/lib/zabbix/zabbix-ldap-sync/zabbix-ldap-sync", line 111, in main zabbix_conn.sync_users() File "/data00/zabbix/zabbix-ldap-sync/lib/zabbixconn.py", line 590, in sync_users if self.ldap_conn.get_user_media(ldap_users[each_user], self.ldap_media): KeyError: 'cwalls'

I was able to work around this issue by commenting out lines 540 and 541 in lib/zabbixconn.py; see screen shot below. There's should probably be a better long term option, which is why I'm opening this issue. This at least allows me to automatically clean up deleted users as expected.

image

scoopex commented 1 year ago

Thanks for investigating and for creating the issue. If you are capable to solve this problem, i invite you to contribute to this opensource project. A submission will be very welcome and i will support you to get it ready for merging.

CompPhy commented 1 year ago

I made a PR, but I'm not sure how to connect it with this issue. I would like to do this myself if possible, do you have instructions for contributing somewhere?