Guest User

Untitled

a guest
Oct 22nd, 2017
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. from MoinMoin.auth.ldap_login import LDAPAuth
  2. ldap_authenticator1 = LDAPAuth(
  3. server_uri='ldap://hermes', # ldap / active directory server URI
  4. bind_dn='user@domain.com', # We can either use some fixed user and password for binding to LDAP.
  5. bind_pw='s3cr3t!!'
  6. base_dn='dc=domain,dc=com', # base DN we use for searching
  7. scope=2, # scope of the search we do (2 == ldap.SCOPE_SUBTREE)
  8. referrals=0, # LDAP REFERRALS (0 needed for AD)
  9. search_filter = '''(&(sAMAccountName=%(username)s)(memberOf=cn=Special\ Group,ou=Groups,dc=domain,dc=com))''' # (AD)
  10. givenname_attribute='givenName', # often 'givenName' - ldap attribute we get the first name from
  11. surname_attribute='sn', # often 'sn' - ldap attribute we get the family name from
  12. aliasname_attribute='displayName', # often 'displayName' - ldap attribute we get the aliasname from
  13. email_attribute='mail', # often 'mail' - ldap attribute we get the email address from
  14. email_callback=None, # callback function called to make up email address
  15. coding='utf-8', # coding used for ldap queries and result values
  16. timeout=10, # how long we wait for the ldap server [s]
  17. start_tls=0, # usage of Transport Layer Security 0 = No, 1 = Try, 2 = Required
  18. tls_cacertdir=None,
  19. tls_cacertfile=None,
  20. tls_certfile=None,
  21. tls_keyfile=None,
  22. tls_require_cert=0, # 0 == ldap.OPT_X_TLS_NEVER (needed for self-signed certs)
  23. bind_once=False, # set to True to only do one bind - useful if configured to bind as the user on the first attempt
  24. autocreate=True, # set to True to automatically create/update user profiles
  25. name='ldap', # use e.g. 'ldap_pdc' and 'ldap_bdc' (or 'ldap1' and 'ldap2') if you auth against 2 ldap servers
  26. report_invalid_credentials=True, # whether to emit "invalid username or password" msg at login time or not
  27. )
  28.  
  29. auth = [
  30. ldap_authenticator1,
  31. ]
  32. cookie_lifetime = (0, 1) # no anon user sessions, 1h session lifetime for logged-in users
Add Comment
Please, Sign In to add comment