From 2e7a01f30adb5e641805f2c37921d111f955f31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Behrmann?= Date: Wed, 9 Apr 2025 10:49:25 +0200 Subject: [PATCH] fix: choose the first mail if multiple are returned from LDAP --- backend/open_webui/routers/auths.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/routers/auths.py b/backend/open_webui/routers/auths.py index 7905799e6..6574ef0b1 100644 --- a/backend/open_webui/routers/auths.py +++ b/backend/open_webui/routers/auths.py @@ -230,11 +230,13 @@ async def ldap_auth(request: Request, response: Response, form_data: LdapForm): entry = connection_app.entries[0] username = str(entry[f"{LDAP_ATTRIBUTE_FOR_USERNAME}"]).lower() - email = str(entry[f"{LDAP_ATTRIBUTE_FOR_MAIL}"]) - if not email or email == "" or email == "[]": + email = entry[f"{LDAP_ATTRIBUTE_FOR_MAIL}"] + if not email: raise HTTPException(400, "User does not have a valid email address.") - else: + elif isinstance(email, str): email = email.lower() + elif isinstance(email, list): + email = email[0].lower() cn = str(entry["cn"]) user_dn = entry.entry_dn