changeset 4931:43c468a525ef

minor ldap auth improvements (see below) Improved debug logging. If you use multiple LDAPAuth instances, you need to have different .name attrs in the instances or moin will complain. Added a 'name' argument (default: 'ldap') that can be used for this.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 27 Jul 2009 19:30:31 +0200
parents c4ee81d47889
children 4c142c453f11
files MoinMoin/auth/ldap_login.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/ldap_login.py	Mon Jul 27 12:46:39 2009 +0200
+++ b/MoinMoin/auth/ldap_login.py	Mon Jul 27 19:30:31 2009 +0200
@@ -83,6 +83,7 @@
         tls_require_cert=0, # 0 == ldap.OPT_X_TLS_NEVER (needed for self-signed certs)
         bind_once=False, # set to True to only do one bind - useful if configured to bind as the user on the first attempt
         autocreate=False, # set to True if you want to autocreate user profiles
+        name='ldap', # use e.g. 'ldap_pdc' and 'ldap_bdc' (or 'ldap1' and 'ldap2') if you auth against 2 ldap servers
         ):
         self.server_uri = server_uri
         self.bind_dn = bind_dn
@@ -111,6 +112,7 @@
 
         self.bind_once = bind_once
         self.autocreate = autocreate
+        self.name = name
 
     def login(self, request, user_obj, **kw):
         username = kw.get('username')
@@ -231,13 +233,14 @@
                 u.name = username
                 u.aliasname = aliasname
                 u.remember_me = 0 # 0 enforces cookie_lifetime config param
-                logging.debug("creating userprefs with name %r email %r alias %r" % (username, email, aliasname))
+                logging.debug("creating user object with name %r email %r alias %r" % (username, email, aliasname))
 
             except ldap.INVALID_CREDENTIALS, err:
                 logging.debug("invalid credentials (wrong password?) for dn %r (username: %r)" % (dn, username))
                 return CancelLogin(_("Invalid username or password."))
 
             if u and self.autocreate:
+                logging.debug("calling create_or_update to autocreate user %r" % u.name)
                 u.create_or_update(True)
             return ContinueLogin(u)