908: Need ability to rewrite email addresses, particularly domains

ted.d******@gmai***** (Google Code) (Is this you? Claim this profile.)
chipx86
chipx86
April 28, 2009
What's the URL of the page containing the problem?


What steps will reproduce the problem?
1. Use active directory auth
2. user in directory has internal only email domain

What is the expected output? What do you see instead?

It would be very nice to be able to rewrite the email address that you get
from any particular authorization scheme.  This is particularly important
with Active Directory because it is common for auth records to have an
internal only email domain that is normally rewritten for external
consumption by the mail transfer agent.  Simply specifying a domain isn't
quite enough because not all address should necessarily be rewritten.

It would be helpful to have a global regex rewrite capability for email
addresses.

The idea would be to specify from and to regexes that would be applied as a
rewrite to email addresses after the address is obtained from the auth system.

What operating system are you using? What browser?


Please provide any additional information below.
#1 hal****@gmai***** (Google Code) (Is this you? Claim this profile.)
I had a very similar problem.
The email addresses that were provided by the code were not correct. I changed the 
code to pull the email from the first 'mail' field instead of using the ad domain.
  • +
    Index: accounts/backends.py
    ===================================================================
    --- accounts/backends.py	(revision 1804)
    +++ accounts/backends.py	(working copy)
    @@ -169,6 +169,8 @@
             root = ['dc=%s' % x for x in self.get_domain_name().split('.')]
             if settings.AD_OU_NAME:
                 root = ['ou=%s' % settings.AD_OU_NAME] + root
    +        if settings.AD_SEARCH_ROOT:
    +            root = [settings.AD_SEARCH_ROOT]
             return ','.join(root)
     
         def search_ad(self, con, filterstr):
    @@ -268,7 +270,9 @@
                 try:
                     first_name = ad_user_data[0][1]['givenName'][0]
                     last_name = ad_user_data[0][1]['sn'][0]
    -                email = u'%s@%s' % (username, settings.AD_DOMAIN_NAME)
    +                email = ad_user_data[0][1]['mail'][0]
    +                if not email: 
    +                  email = u'%s@%s' % (username, settings.AD_DOMAIN_NAME)
     
                     user = User(username=username,
                                 password
chipx86
#2 chipx86
Can you post this on http://reviews.review-board.org/ ?
  • +Confirmed
  • -Type-Defect
    +Type-Enhancement
    +Component-Accounts
    +Milestone-Release1.0
chipx86
#3 chipx86
Committed a variation of this as r1938.
  • -Confirmed
    +Fixed
  • +chipx86