Skip to content

LDAPSchemaError: schema not present due to lack of argument validation in LDAPSettings #28

@mardukbp

Description

@mardukbp

Describe the bug

When the USERNAME and PASSWORD of LDAPSettings are both None preloading the connection to the domain and synchronizing a user fail with the exception LDAPSchemaError: schema not present.

To Reproduce

Steps to reproduce the behavior:

  1. In the settings.py file of the Django project configure WAUTH_DOMAINS calling the constructor of LDAPSettings with USERNAME set to os.environ.get('NONEXISTENT_USER_VAR') and PASSWORD set to os.environ.get('NONEXISTENT_PASSWORD_VAR')
  2. Wait for the Django server to reload
  3. In a web browser open the root URL of the Django project

Expected behavior

The constructor of LDAPSettings validates its arguments and throws an exception whenever USERNAME or PASSWORD is None. That way an invalid Connection object is not passed to the underlying ldap3 library, which throws an exception that is unrelated to the USERNAME and PASSWORD being wrong.

Screenshots

N/A

Versions (please complete the following information):

  • OS: Windows Server 2016
  • IIS Version 10
  • Django Version 4.2
  • Python Version 3.11

Additional context

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions