Skip to content
Snippets Groups Projects
Verified Commit 1fed8f2e authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Ignore missing LDAP fields on match

parent 6561e392
No related branches found
No related tags found
1 merge request!28Resolve "Allow match of users to persons by other fields in AlekSIS and LDAP"
......@@ -238,7 +238,12 @@ def ldap_sync_from_user(user, dn, attrs):
# Match on all fields selected in preferences
fields_map = {f.name: f for f in Person.syncable_fields()}
for field_name in get_site_preferences()["ldap__matching_fields"]:
value = get_ldap_value_for_field(Person, fields_map[field_name], attrs, dn)
try:
value = get_ldap_value_for_field(Person, fields_map[field_name], attrs, dn)
except KeyError:
# Field is not set in LDAP, match on remaining fields
continue
matches[field_name] = value
# Pre-fill all mandatory non-matching fields from User object
for missing_key in ("first_name", "last_name", "email"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment