I can't find the link but here is my sanitised config:
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
#
#
# Server URI
AUTH_LDAP_SERVER_URI = "ldaps://ldapserver.domain.local"
# The following may be needed if you are binding to Active Directory.
AUTH_LDAP_CONNECTION_OPTIONS = {
ldap.OPT_REFERRALS: 0
}
# Set the DN and password for the NetBox service account.
AUTH_LDAP_BIND_DN = "user...@domain.local"
AUTH_LDAP_BIND_PASSWORD = "passwordforuser"
# Include this setting if you want to ignore certificate errors. This might be needed to accept a self-signed cert.
# Note that this is a NetBox-specific setting which sets:
# ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
LDAP_IGNORE_CERT_ERRORS = True
#
#
#
#
# Where to look for users
# "(sAMAccountName=%(user)s)")
AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=Users,OU=YOURCOMPANY,DC=domain,DC=local", ldap.SCOPE_SUBTREE,
"(sAMAccountName=%(user)s)")
# This search ought to return all groups to which the user belongs. django_auth_ldap uses this to determine group
# hierarchy.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Groups,ou=YOURCOMPANY,dc=domain,dc=local", ldap.SCOPE_SUBTREE,
"(objectClass=group)")
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
# Map user attributes to Django attributes
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
# Mirror LDAP group assignments.
AUTH_LDAP_MIRROR_GROUPS = True
# Define special user types using groups. Exercise great caution when assigning superuser status.
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_active": "CN=AllUsers,CN=Users,DC=domain,DC=local",
"is_staff": "cn=StaffUsers,ou=Groups,ou=YOURCOMPANY,dc=domain,dc=local",
"is_superuser": "cn=SuperUsers,ou=Groups,ou=YOURCOMPANY,dc=domain,dc=local"
}
# For more granular permissions, we can map LDAP groups to Django groups.
AUTH_LDAP_FIND_GROUP_PERMS = True
# Cache groups for one hour to reduce LDAP traffic
AUTH_LDAP_CACHE_TIMEOUT = 3600