django-auth-ldap installation not working

django-auth-ldap needs to be compiled due to its dependencies. Especially on Windows, I'd recommend trying a pure Python solution. The one I use which works very well, is django-python3-ldap, which you can find here:

https://github.com/etianen/django-python3-ldap

Here is how I set up the settings, so that we can connect using these values with ldap3 directly as well:

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_python3_ldap.auth.LDAPBackend',
]

# LDAP Connection Settings
LDAP_AUTH_HOST = 'ldap.example.com'
LDAP_AUTH_PORT = 636
LDAP_AUTH_URL = 'ldaps://{host}:{port}'.format(
    host=LDAP_AUTH_HOST,
    port=LDAP_AUTH_PORT,
)
LDAP_AUTH_CONNECTION_USERNAME = 'ldapuser'
LDAP_AUTH_CONNECTION_PASSWORD = 'ldappassword'

# Initiate TLS on connection.
LDAP_AUTH_USE_TLS = True

# The LDAP search base for looking up users.
LDAP_AUTH_SEARCH_BASE = "ou=People,dc=example,dc=com"

# The LDAP class that represents a user.
LDAP_AUTH_OBJECT_CLASS = "shadowAccount"

# User model fields mapped to the LDAP
# attributes that represent them.
LDAP_AUTH_USER_FIELDS = {
    "username": "uid",
}

# A tuple of fields used to uniquely identify a user.
LDAP_AUTH_USER_LOOKUP_FIELDS = ("username",)

The README also includes instructions for Active Directory, if that's what you're connecting to. Good luck!


For those who, like me, cannot leave django-auth-ldap for whatever reason: I solved downloading and installing the binary wheel of python-ldap from here

https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

I hope this helps