zabbix-tooling / zabbix-ldap-sync

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

Zabbix 5.4 API change #32

Closed Skifi closed 3 years ago

Skifi commented 3 years ago

Hello, I am trying to configure ldap-sync but i get error:

2021-06-02 09:46:39,489 - INFO - pyzabbix:65 - JSON-RPC Server Endpoint: http://myzabbixserver/zabbix/api_jsonrpc.php 2021-06-02 09:46:39,539 - INFO - ZabbixConn:69 - Connected to Zabbix API Version 5.4.0 Traceback (most recent call last): File "/etc/zabbix/zabbix-ldap-sync-master/zabbix-ldap-sync", line 103, in main() File "/etc/zabbix/zabbix-ldap-sync-master/zabbix-ldap-sync", line 99, in main zabbix_conn.sync_users() File "/etc/zabbix/zabbix-ldap-sync-master/lib/zabbixconn.py", line 355, in sync_users zabbix_all_users = [x.lower() for x in self.get_users()] File "/etc/zabbix/zabbix-ldap-sync-master/lib/zabbixconn.py", line 81, in get_users users = [user['alias'] for user in result] File "/etc/zabbix/zabbix-ldap-sync-master/lib/zabbixconn.py", line 81, in users = [user['alias'] for user in result] KeyError: 'alias'

When i tried to debug this i found new change in zabbix API 5.4 release notes. Can you please make fix for this.

Changed field "alias" into "username" https://support.zabbix.com/browse/ZBXNEXT-1215 https://support.zabbix.com/browse/ZBXNEXT-6474

scoopex commented 3 years ago

Thanks for reporting. Seems to be a easy task to fix that. We should introduce a version comparison in the code (if self.conn.api_version() >= "5.2":) automatically adapt the behavior.

Probably you can contribute a fix for that? (i currently use zabbix 5.2.6 and i will update in a few weeks)

scoopex commented 3 years ago

I still do not own a 5.4 setup, but i implemented that :-) Can you verify that it is working now?

scoopex commented 3 years ago

No response, seems to be ok.