From 4724acdebcfa92df269ca5ac8d90eb1c6b84173c Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Thu, 24 Feb 2022 09:56:49 -0500 Subject: [PATCH] Handle when Azure AD returns byte/list for contact mode --- src/oncall/user_sync/ldap_sync.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/oncall/user_sync/ldap_sync.py b/src/oncall/user_sync/ldap_sync.py index 362e1ed4..ef9a8ece 100644 --- a/src/oncall/user_sync/ldap_sync.py +++ b/src/oncall/user_sync/ldap_sync.py @@ -238,6 +238,12 @@ def update_user(username, ldap_contacts, engine): stats['user_photos_updated'] += 1 for mode in modes: if mode in ldap_contacts and ldap_contacts[mode]: + if isinstance(ldap_contacts[mode], list): + ldap_contacts[mode] = ldap_contacts[mode][0] + try: + ldap_contacts[mode] = ldap_contacts[mode].decode() + except (UnicodeDecodeError, AttributeError): + pass if mode in db_contacts: if ldap_contacts[mode] != db_contacts[mode]: logger.debug('\tupdating %s (%s -> %s)' % (mode, db_contacts[mode], ldap_contacts[mode])) @@ -372,6 +378,12 @@ def sync(config, engine): stats['user_photos_updated'] += 1 for mode in modes: if mode in ldap_contacts and ldap_contacts[mode]: + if isinstance(ldap_contacts[mode], list): + ldap_contacts[mode] = ldap_contacts[mode][0] + try: + ldap_contacts[mode] = ldap_contacts[mode].decode() + except (UnicodeDecodeError, AttributeError): + pass if mode in db_contacts: if ldap_contacts[mode] != db_contacts[mode]: logger.debug('\tupdating %s', mode)