Guest User

Untitled

a guest
Oct 26th, 2021
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. import ldap
  2.  
  3. # Server URI
  4. AUTH_LDAP_SERVER_URI = "ldap://xxx.com"
  5.  
  6. # The following may be needed if you are binding to Active Directory.
  7. AUTH_LDAP_CONNECTION_OPTIONS = {
  8. ldap.OPT_REFERRALS: 0
  9. }
  10.  
  11. # Set the DN and password for the NetBox service account.
  12. AUTH_LDAP_BIND_DN = "CN=account,OU=xxx,OU=xxx,OU=xxx,OU=xxx,OU=xxx,DC=xxx"
  13. AUTH_LDAP_BIND_PASSWORD = "password"
  14.  
  15. # Include this setting if you want to ignore certificate errors. This might be needed to accept a self-signed cert.
  16. # Note that this is a NetBox-specific setting which sets:
  17. # ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
  18. LDAP_IGNORE_CERT_ERRORS = True
  19.  
  20.  
  21. from django_auth_ldap.config import LDAPSearch
  22.  
  23. # This search matches users with the sAMAccountName equal to the provided username. This is required if the user's
  24. # username is not in their DN (Active Directory).
  25. AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=AdminUsers,OU=Admin,OU=xxx,DC=xxxxxx,DC=com",
  26. ldap.SCOPE_SUBTREE,
  27. "(sAMAccountName=%(user)s)")
  28.  
  29. # If a user's DN is producible from their username, we don't need to search.
  30. #AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,OU=AdminUsers,OU=Admin,OU=xxx,DC=xxxxxx,DC=com"
  31.  
  32. # You can map user attributes to Django attributes as so.
  33. #AUTH_LDAP_USER_ATTR_MAP = {
  34. # "username": "sAMAccountName",
  35. # "first_name": "givenName",
  36. # "last_name": "sn",
  37. # "email": "mail"
  38. #}
  39.  
  40. # You can map user attributes to Django attributes as so
  41. AUTH_LDAP_USER_ATTR_MAP = {
  42. "username": "sAMAccountName",
  43. "first_name": "givenName",
  44. "last_name": "sn",
  45. "email": "mail"
  46. }
  47.  
  48.  
  49. from django_auth_ldap.config import LDAPSearch, NestedxxxOfNamesType
  50.  
  51. # This search ought to return all xxxs to which the user belongs. django_auth_ldap uses this to determine xxx
  52. # hierarchy.
  53. AUTH_LDAP_xxx_SEARCH = LDAPSearch("dc=xxxxxx,dc=com", ldap.SCOPE_SUBTREE,
  54. "(objectClass=xxx)")
  55. AUTH_LDAP_xxx_TYPE = NestedxxxOfNamesType()
  56.  
  57. # Define a xxx required to login.
  58. AUTH_LDAP_REQUIRE_xxx = "CN=xxx-Netbox-Users,OU=xxx,OU=xxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com"
  59.  
  60. # Mirror LDAP xxx assignments.
  61. #AUTH_LDAP_MIRROR_xxxS = True
  62.  
  63. # Define special user types using xxxs. Exercise great caution when assigning superuser status.
  64.  
  65. AUTH_LDAP_USER_FLAGS_BY_xxx = {
  66. "is_active": "CN=xxx-Netbox-Users,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com",
  67. "is_staff": "CN=xxx-Netbox-Admin,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com",
  68. "is_superuser": "CN=xxx-Netbox-SprAdmin,OU=xxx xxxs,OU=Globalxxxs,OU=xxx,OU=xxx,DC=xxxxxx,DC=com"
  69. }
  70.  
  71. # For more granular permissions, we can map LDAP xxxs to Django xxxs.
  72. AUTH_LDAP_FIND_xxx_PERMS = True
  73.  
  74. # Cache xxxs for one hour to reduce LDAP traffic
  75. AUTH_LDAP_CACHE_TIMEOUT = 3600
  76. AUTH_LDAP_CACHE_xxxS = True
  77.  
Advertisement
Add Comment
Please, Sign In to add comment