changeset 2985:af66750c66e4

don't overwrite email in userprofile with (empty) email addr from ldap (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 16:02:03 +0100
parents 52f9d511f155
children d6fb846dc73c
files MoinMoin/auth/ldap_login.py MoinMoin/config/multiconfig.py
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/ldap_login.py	Sun Jan 06 04:45:56 2008 +0100
+++ b/MoinMoin/auth/ldap_login.py	Sun Jan 06 16:02:03 2008 +0100
@@ -103,8 +103,11 @@
                 l.simple_bind_s(dn, password.encode(coding))
                 if verbose: request.log("LDAP: Bound with dn %r (username: %r)" % (dn, username))
 
-                if getattr(cfg, "ldap_email_callback", None) is None:
-                    email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0].decode(coding)
+                if cfg.ldap_email_callback is None:
+                    if cfg.ldap_email_attribute:
+                        email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0].decode(coding)
+                    else:
+                        email = None
                 else:
                     email = cfg.ldap_email_callback(ldap_dict)
 
@@ -120,10 +123,13 @@
                         aliasname = sn
                 aliasname = aliasname.decode(coding)
 
-                u = user.User(request, auth_username=username, password="{SHA}NotStored", auth_method=self.name, auth_attribs=('name', 'password', 'email', 'mailto_author', ))
+                if email:
+                    u = user.User(request, auth_username=username, password="{SHA}NotStored", auth_method=self.name, auth_attribs=('name', 'password', 'email', 'mailto_author',))
+                    u.email = email
+                else:
+                    u = user.User(request, auth_username=username, password="{SHA}NotStored", auth_method=self.name, auth_attribs=('name', 'password', 'mailto_author',))
                 u.name = username
                 u.aliasname = aliasname
-                u.email = email
                 u.remember_me = 0 # 0 enforces cookie_lifetime config param
                 if verbose: request.log("LDAP: creating userprefs with name %r email %r alias %r" % (username, email, aliasname))
 
--- a/MoinMoin/config/multiconfig.py	Sun Jan 06 04:45:56 2008 +0100
+++ b/MoinMoin/config/multiconfig.py	Sun Jan 06 16:02:03 2008 +0100
@@ -362,6 +362,7 @@
     ldap_surname_attribute = None # ('sn') ldap attribute we get the family name from
     ldap_aliasname_attribute = None # ('displayName') ldap attribute we get the aliasname from
     ldap_email_attribute = None # ('mail') ldap attribute we get the email address from
+    ldap_email_callback = None # called to make up email address
 
     ldap_coding = 'utf-8' # coding used for ldap queries and result values
     ldap_timeout = 10 # how long we wait for the ldap server [s]