From d10f0cd0574c50a07137e98d74fc06c3dcdfed75 Mon Sep 17 00:00:00 2001 From: Michael Wilmes Date: Thu, 18 Dec 2025 08:17:52 -0800 Subject: [PATCH] Use the directory username to search when changing the email --- user_sync/engine/umapi.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/user_sync/engine/umapi.py b/user_sync/engine/umapi.py index a1b8762b..211a9234 100644 --- a/user_sync/engine/umapi.py +++ b/user_sync/engine/umapi.py @@ -894,7 +894,13 @@ def update_umapi_user(self, umapi_info, user_key, attributes_to_update=None, gro directory_user['email'] = umapi_user['email'] directory_user['username'] = umapi_user['email'] - commands = user_sync.connector.connector_umapi.Commands(directory_user['email'], directory_user['domain']) + # if the username is not an email address, matches in both directories, and the email address is changing, then we need to lookup by username. + if '@' not in directory_user['username'] and directory_user['username'] == umapi_user['username'] and normalize_string(directory_user['email']) != normalize_string(umapi_user['email']): + user_lookup = directory_user['username'] + else: + user_lookup = directory_user['email'] + + commands = user_sync.connector.connector_umapi.Commands(user_lookup, directory_user['domain']) commands.update_user(attributes_to_update) commands.remove_groups(groups_to_remove) commands.add_groups(groups_to_add)