Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ldap
- # Server URI
- AUTH_LDAP_SERVER_URI = "ldap://xxx.com"
- # 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 = "CN=account,OU=xxx,OU=xxx,OU=xxx,OU=xxx,OU=xxx,DC=xxx"
- AUTH_LDAP_BIND_PASSWORD = "password"
- # 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
- from django_auth_ldap.config import LDAPSearch
- # This search matches users with the sAMAccountName equal to the provided username. This is required if the user's
- # username is not in their DN (Active Directory).
- AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=AdminUsers,OU=Admin,OU=xxx,DC=xxxxxx,DC=com",
- ldap.SCOPE_SUBTREE,
- "(sAMAccountName=%(user)s)")
- # If a user's DN is producible from their username, we don't need to search.
- #AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,OU=AdminUsers,OU=Admin,OU=xxx,DC=xxxxxx,DC=com"
- # You can map user attributes to Django attributes as so.
- #AUTH_LDAP_USER_ATTR_MAP = {
- # "username": "sAMAccountName",
- # "first_name": "givenName",
- # "last_name": "sn",
- # "email": "mail"
- #}
- # You can map user attributes to Django attributes as so
- AUTH_LDAP_USER_ATTR_MAP = {
- "username": "sAMAccountName",
- "first_name": "givenName",
- "last_name": "sn",
- "email": "mail"
- }
- from django_auth_ldap.config import LDAPSearch, NestedxxxOfNamesType
- # This search ought to return all xxxs to which the user belongs. django_auth_ldap uses this to determine xxx
- # hierarchy.
- AUTH_LDAP_xxx_SEARCH = LDAPSearch("dc=xxxxxx,dc=com", ldap.SCOPE_SUBTREE,
- "(objectClass=xxx)")
- AUTH_LDAP_xxx_TYPE = NestedxxxOfNamesType()
- # Define a xxx required to login.
- AUTH_LDAP_REQUIRE_xxx = "CN=xxx-Netbox-Users,OU=xxx,OU=xxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com"
- # Mirror LDAP xxx assignments.
- #AUTH_LDAP_MIRROR_xxxS = True
- # Define special user types using xxxs. Exercise great caution when assigning superuser status.
- AUTH_LDAP_USER_FLAGS_BY_xxx = {
- "is_active": "CN=xxx-Netbox-Users,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com",
- "is_staff": "CN=xxx-Netbox-Admin,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com",
- "is_superuser": "CN=xxx-Netbox-SprAdmin,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com"
- }
- # For more granular permissions, we can map LDAP xxxs to Django xxxs.
- AUTH_LDAP_FIND_xxx_PERMS = True
- # Cache xxxs for one hour to reduce LDAP traffic
- AUTH_LDAP_CACHE_TIMEOUT = 3600
- AUTH_LDAP_CACHE_xxxS = True
Advertisement
Add Comment
Please, Sign In to add comment