changeset 2234:b39475e79845

Introduce a callback to generate e-mail addresses for LDAP-imported accounts.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 21 Jun 2007 09:42:32 +0200
parents 666625ecde91
children fcb18262e270
files MoinMoin/auth/ldap_login.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/ldap_login.py	Thu May 31 11:35:20 2007 +0200
+++ b/MoinMoin/auth/ldap_login.py	Thu Jun 21 09:42:32 2007 +0200
@@ -1,3 +1,12 @@
+-             email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0]
+-             email = email.decode(coding)
+--- 98,107 ----
+              l.simple_bind_s(dn, password.encode(coding))
+              if verbose: request.log("LDAP: Bound with dn %s (username: %s)" % (dn, username))
+  
+  
+              aliasname = ''
+              try:
 # -*- coding: iso-8859-1 -*-
 """
     MoinMoin - LDAP / Active Directory authentication
@@ -101,8 +110,10 @@
                 l.simple_bind_s(dn, password.encode(coding))
                 if verbose: request.log("LDAP: Bound with dn %s (username: %s)" % (dn, username))
 
-                email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0]
-                email = email.decode(coding)
+                if getattr(cfg, "ldap_email_callback", None) is None:
+                    email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0].decode(coding)
+                else:
+                    email = cfg.ldap_email_callback(ldap_dict)
 
                 aliasname = ''
                 try: