changeset 4634:28a5a548d6f5

ldap auth: new name_callback param to create a custom wiki username (not the ldap login username). Thanks to Heinrich Wendel for the patch.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Mar 2009 13:33:58 +0100
parents a306904a3620
children 716dcfb00e8e
files MoinMoin/auth/ldap_login.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/ldap_login.py	Tue Feb 24 10:08:55 2009 +0100
+++ b/MoinMoin/auth/ldap_login.py	Tue Mar 03 13:33:58 2009 +0100
@@ -72,6 +72,7 @@
         aliasname_attribute=None, # ('displayName') ldap attribute we get the aliasname from
         email_attribute=None, # ('mail') ldap attribute we get the email address from
         email_callback=None, # called to make up email address
+        name_callback=None, # called to use a Wiki name different from the login name
         coding='utf-8', # coding used for ldap queries and result values
         timeout=10, # how long we wait for the ldap server [s]
         start_tls=0, # 0 = No, 1 = Try, 2 = Required
@@ -96,6 +97,7 @@
         self.aliasname_attribute = aliasname_attribute
         self.email_attribute = email_attribute
         self.email_callback = email_callback
+        self.name_callback = name_callback
 
         self.coding = coding
         self.timeout = timeout
@@ -218,6 +220,9 @@
                         aliasname = sn
                 aliasname = aliasname.decode(coding)
 
+                if self.name_callback:
+                    username = self.name_callback(ldap_dict)
+
                 if email:
                     u = user.User(request, auth_username=username, auth_method=self.name, auth_attribs=('name', 'password', 'email', 'mailto_author', ))
                     u.email = email