mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
ldap: Continue syncing other fields even if a field is missing.
Earlier the behavior was to raise an exception thereby stopping the whole sync. Now we log an error message and skip the field. Also fixes the `query_ldap` command to report missing fields without error. Fixes: #11780.
This commit is contained in:
committed by
Tim Abbott
parent
58d28eed5d
commit
4a9bd89f47
@@ -347,7 +347,13 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend):
|
||||
if not attr.startswith('custom_profile_field__'):
|
||||
continue
|
||||
var_name = attr.split('custom_profile_field__')[1]
|
||||
value = ldap_user.attrs[ldap_attr][0]
|
||||
try:
|
||||
value = ldap_user.attrs[ldap_attr][0]
|
||||
except KeyError:
|
||||
# If this user doesn't have this field set then ignore this
|
||||
# field and continue syncing other fields. `django-auth-ldap`
|
||||
# automatically logs error about missing field.
|
||||
continue
|
||||
values_by_var_name[var_name] = value
|
||||
|
||||
fields_by_var_name = {} # type: Dict[str, CustomProfileField]
|
||||
|
||||
Reference in New Issue
Block a user