issue: Administration with LDAP User not accessible after upgrade to 0.5.19 #4253

Closed
opened 2025-11-11 15:49:36 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @Pacman1988 on GitHub (Mar 5, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.

Installation Method

Docker

Open WebUI Version

0.5.19

Ollama Version (if applicable)

Operating System

Windows 11

Browser (if applicable)

Edge

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have checked the browser console logs.
  • I have checked the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

Login and can go to Admin Panel with LDAP Administrator User, like E-Mail User:

Image

Actual Behavior

Login and no Admin Panel there like normal user. Trying to access /admin does also not help and redirect to main page.

Image

Steps to Reproduce

Upgrade from older version to 0.5.19.

Logs & Screenshots

See upper screenshots,

Additional Information

Maybe its related to the update notes:
v0.5.19 - 2024-03-04
LDAP Email Case Sensitivity
Resolved an issue where LDAP login failed due to email case sensitivity mismatches, improving authentication reliability.

No response

Originally created by @Pacman1988 on GitHub (Mar 5, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Installation Method Docker ### Open WebUI Version 0.5.19 ### Ollama Version (if applicable) - ### Operating System Windows 11 ### Browser (if applicable) Edge ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have checked the browser console logs. - [x] I have checked the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior Login and can go to Admin Panel with LDAP Administrator User, like E-Mail User: ![Image](https://github.com/user-attachments/assets/b757a29f-b775-4cb8-a0c6-06f8cf4132c8) ### Actual Behavior Login and no Admin Panel there like normal user. Trying to access /admin does also not help and redirect to main page. ![Image](https://github.com/user-attachments/assets/a04c11f9-3636-49a6-84be-e4720966bba4) ### Steps to Reproduce Upgrade from older version to 0.5.19. ### Logs & Screenshots See upper screenshots, ### Additional Information Maybe its related to the update notes: v0.5.19 - 2024-03-04 LDAP Email Case Sensitivity Resolved an issue where LDAP login failed due to email case sensitivity mismatches, improving authentication reliability. _No response_
GiteaMirror added the bug label 2025-11-11 15:49:36 -06:00
Author
Owner

@tjbck commented on GitHub (Mar 5, 2025):

You should manually update the database to lowercase the emails.

Here's an example code you can run:

from sqlalchemy import create_engine, Column, String, Boolean, Text, BigInteger
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import json

Base = declarative_base()

class User(Base):
    __tablename__ = "user"

    id = Column(String, primary_key=True)
    name = Column(String)
    email = Column(String)
    role = Column(String)
    profile_image_url = Column(Text)

    last_active_at = Column(BigInteger)
    updated_at = Column(BigInteger)
    created_at = Column(BigInteger)

    api_key = Column(String, nullable=True, unique=True)
    settings = Column(Text, nullable=True)  # Using Text to store JSON
    info = Column(Text, nullable=True)  # Using Text to store JSON

    oauth_sub = Column(Text, unique=True)

class Auth(Base):
    __tablename__ = "auth"

    id = Column(String, primary_key=True)
    email = Column(String)
    password = Column(Text)
    active = Column(Boolean)

# Database connection setup (modify this with your database URL)
DATABASE_URL = "sqlite:///example.db"  # Replace with your actual DB connection URL
engine = create_engine(DATABASE_URL)
Session = sessionmaker(bind=engine)
session = Session()

# Function to update emails to lowercase
def lowercase_emails():
    # Update emails in the User table
    users = session.query(User).filter(User.email.isnot(None)).all()
    for user in users:
        user.email = user.email.lower()

    # Update emails in the Auth table
    auth_entries = session.query(Auth).filter(Auth.email.isnot(None)).all()
    for auth in auth_entries:
        auth.email = auth.email.lower()

    # Commit changes
    session.commit()
    print("Emails have been updated to lowercase.")

# Run the function
lowercase_emails()

# Close the session
session.close()
@tjbck commented on GitHub (Mar 5, 2025): You should manually update the database to lowercase the emails. Here's an example code you can run: ```py from sqlalchemy import create_engine, Column, String, Boolean, Text, BigInteger from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker import json Base = declarative_base() class User(Base): __tablename__ = "user" id = Column(String, primary_key=True) name = Column(String) email = Column(String) role = Column(String) profile_image_url = Column(Text) last_active_at = Column(BigInteger) updated_at = Column(BigInteger) created_at = Column(BigInteger) api_key = Column(String, nullable=True, unique=True) settings = Column(Text, nullable=True) # Using Text to store JSON info = Column(Text, nullable=True) # Using Text to store JSON oauth_sub = Column(Text, unique=True) class Auth(Base): __tablename__ = "auth" id = Column(String, primary_key=True) email = Column(String) password = Column(Text) active = Column(Boolean) # Database connection setup (modify this with your database URL) DATABASE_URL = "sqlite:///example.db" # Replace with your actual DB connection URL engine = create_engine(DATABASE_URL) Session = sessionmaker(bind=engine) session = Session() # Function to update emails to lowercase def lowercase_emails(): # Update emails in the User table users = session.query(User).filter(User.email.isnot(None)).all() for user in users: user.email = user.email.lower() # Update emails in the Auth table auth_entries = session.query(Auth).filter(Auth.email.isnot(None)).all() for auth in auth_entries: auth.email = auth.email.lower() # Commit changes session.commit() print("Emails have been updated to lowercase.") # Run the function lowercase_emails() # Close the session session.close() ```
Author
Owner

@Pacman1988 commented on GitHub (Mar 5, 2025):

Can you tell me how to do this in my docker container? Because the docker container does not have a text editor like vi or nano and I cannot even install one to run the script.

Can't you do it with db migration in the next update? Will this not affect more users?

@Pacman1988 commented on GitHub (Mar 5, 2025): Can you tell me how to do this in my docker container? Because the docker container does not have a text editor like vi or nano and I cannot even install one to run the script. Can't you do it with db migration in the next update? Will this not affect more users?
Author
Owner

@Classic298 commented on GitHub (Mar 5, 2025):

Do you use sqlite? External PostgreSQL?
If external, just connect to the DB
If SQLITE, move the script inside the docker container and execute it on the sqlite file?

@Classic298 commented on GitHub (Mar 5, 2025): Do you use sqlite? External PostgreSQL? If external, just connect to the DB If SQLITE, move the script inside the docker container and execute it on the sqlite file?
Author
Owner

@Pacman1988 commented on GitHub (Mar 5, 2025):

I hope it helps others, but Im not satisfied to fix it myself when the application broke it.

Steps to fix with SQLITE and Docker Image

  1. Create fix.py and change connection string to DATABASE_URL (I used the default Docker Container so it is webui.db - you can find it with docker exec -it open-webui ls data and there is a *.db file)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import json

Base = declarative_base()

class User(Base):
    __tablename__ = "user"

    id = Column(String, primary_key=True)
    name = Column(String)
    email = Column(String)
    role = Column(String)
    profile_image_url = Column(Text)

    last_active_at = Column(BigInteger)
    updated_at = Column(BigInteger)
    created_at = Column(BigInteger)

    api_key = Column(String, nullable=True, unique=True)
    settings = Column(Text, nullable=True)  # Using Text to store JSON
    info = Column(Text, nullable=True)  # Using Text to store JSON

    oauth_sub = Column(Text, unique=True)

class Auth(Base):
    __tablename__ = "auth"

    id = Column(String, primary_key=True)
    email = Column(String)
    password = Column(Text)
    active = Column(Boolean)

# Database connection setup (modify this with your database URL)
DATABASE_URL = "sqlite:///webui.db"  # Replace with your actual DB connection URL
engine = create_engine(DATABASE_URL)
Session = sessionmaker(bind=engine)
session = Session()

# Function to update emails to lowercase
def lowercase_emails():
    # Update emails in the User table
    users = session.query(User).filter(User.email.isnot(None)).all()
    for user in users:
        user.email = user.email.lower()

    # Update emails in the Auth table
    auth_entries = session.query(Auth).filter(Auth.email.isnot(None)).all()
    for auth in auth_entries:
        auth.email = auth.email.lower()

    # Commit changes
    session.commit()
    print("Emails have been updated to lowercase.")

# Run the function
lowercase_emails()

# Close the session
session.close()
  1. Copy the Script into the docker container

docker cp fix.py open-webui:/app/backend/data/

  1. Go into a Shell

docker exec -it open-webui /bin/sh

  1. Switch to directory

cd data

  1. Run python script

python fix.py

  1. Output should show

Emails have been updated to lowercase.

@Pacman1988 commented on GitHub (Mar 5, 2025): I hope it helps others, but Im not satisfied to fix it myself when the application broke it. # Steps to fix with SQLITE and Docker Image 1. Create fix.py and change connection string to DATABASE_URL (I used the default Docker Container so it is `webui.db` - you can find it with `docker exec -it open-webui ls data` and there is a *.db file) ```from sqlalchemy import create_engine, Column, String, Boolean, Text, BigInteger from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker import json Base = declarative_base() class User(Base): __tablename__ = "user" id = Column(String, primary_key=True) name = Column(String) email = Column(String) role = Column(String) profile_image_url = Column(Text) last_active_at = Column(BigInteger) updated_at = Column(BigInteger) created_at = Column(BigInteger) api_key = Column(String, nullable=True, unique=True) settings = Column(Text, nullable=True) # Using Text to store JSON info = Column(Text, nullable=True) # Using Text to store JSON oauth_sub = Column(Text, unique=True) class Auth(Base): __tablename__ = "auth" id = Column(String, primary_key=True) email = Column(String) password = Column(Text) active = Column(Boolean) # Database connection setup (modify this with your database URL) DATABASE_URL = "sqlite:///webui.db" # Replace with your actual DB connection URL engine = create_engine(DATABASE_URL) Session = sessionmaker(bind=engine) session = Session() # Function to update emails to lowercase def lowercase_emails(): # Update emails in the User table users = session.query(User).filter(User.email.isnot(None)).all() for user in users: user.email = user.email.lower() # Update emails in the Auth table auth_entries = session.query(Auth).filter(Auth.email.isnot(None)).all() for auth in auth_entries: auth.email = auth.email.lower() # Commit changes session.commit() print("Emails have been updated to lowercase.") # Run the function lowercase_emails() # Close the session session.close() ``` 2. Copy the Script into the docker container `docker cp fix.py open-webui:/app/backend/data/` 3. Go into a Shell `docker exec -it open-webui /bin/sh` 4. Switch to directory `cd data` 5. Run python script `python fix.py` 6. Output should show `Emails have been updated to lowercase.`
Author
Owner

@Classic298 commented on GitHub (Mar 5, 2025):

yeah i can understand you. the application should've migrated the emails in the database

@Classic298 commented on GitHub (Mar 5, 2025): yeah i can understand you. the application should've migrated the emails in the database
Author
Owner

@ips972 commented on GitHub (Mar 20, 2025):

did you not see my post about this, as soon as this error started appearing i opened a discussions on it.
ldap authentication causing duplicate users since CASE sensitive issue was "fixed" #11513

with no response from management :-)
still causing duplication of accounts in my net, until all users finish re-login.

@ips972 commented on GitHub (Mar 20, 2025): did you not see my post about this, as soon as this error started appearing i opened a discussions on it. ldap authentication causing duplicate users since CASE sensitive issue was "fixed" #11513 with no response from management :-) still causing duplication of accounts in my net, until all users finish re-login.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#4253