Modify

Opened 10 years ago

Last modified 4 years ago

#11411 new enhancement

Add LDAP E-mail Resolving

Reported by: Rolando Nieves Owned by:
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords: ldap
Cc: Trac Release: 1.0

Description

At our Trac site we have an OpenLDAP directory that serves as the central authentication point for workstations, SVN, and Trac. In it we have put all of our pertinent information, including a valid e-mail address.

After getting the AnnouncerPlugin working I wondered if I could extend it to include a "resolver" (as it is called in the plugin's parlance) that would look up user's e-mail address in the LDAP directory. I believe I was able to get at least a good start down that path. Attached to this ticket I have included a diff patch for the announcer/resolvers.py file which creates a new e-mail resolver: LdapEmailResolver.

The resolver carries with it several configuration options. All of the details of how to use these options is in the announcer/resolvers.py file.

I realize that all of this work will be overcome by events once IUserProvider is rolled out and the appropriate components are written against it. But, for now, this fit the bill just fine for me. I'm submitting it in the hope that it is useful to others.

Attachments (2)

announcerplugin_ldappatch.diff (4.4 KB) - added by Rolando Nieves 10 years ago.
LDAP e-mail resolver patch
trac_ldap_email - Copy.diff (42.9 KB) - added by shorif2000 10 years ago.
notification.py under trac

Download all attachments as: .zip

Change History (13)

Changed 10 years ago by Rolando Nieves

LDAP e-mail resolver patch

comment:1 Changed 10 years ago by Steffen Hoffmann

Cc: Ryan J Ollos added; anonymous removed

Thank you for your valuable contribution.

I'd appreciate at least on independent test of the patch, because I've no suitable environment. By chance: Is it possible (for you) to contribute some unit tests for the new component and its methods too? I ask this in recognition of my nearly total absence of experience with LDAP.

comment:2 Changed 10 years ago by bkn@…

I'd like to add to this ticket that I have used this patch and it worked once i figured out the necessary configuration variables. Good work and thank you! Please apply this patch to the Announcer plugin as i can confirm it works. (and please add a tiny example config for ldap section)

comment:3 Changed 10 years ago by Steffen Hoffmann

#11559, that recommends a rename of configuration options, has been closed as a duplicate of this ticket.

comment:4 Changed 10 years ago by Steffen Hoffmann

#11936 has been closed as a duplicate for asking about the enhancement suggested here.

comment:5 Changed 10 years ago by shorif2000

This is not working for me on trac 1.01. for trac 0.12 i created a plugin. any suggestions to get this working for trac 1.01?

SO

After i have pacthed. I have played around with email_address_resolvers, just keeping LdapEmailResolver or addign others makes no difference to LdapEmailResolver. Also it CC's the notification section and not announcer section.

[announcer]
email_address_resolvers = SessionEmailResolver, LdapEmailResolver
email_enabled = true
email_from = trac@domain.com
email_from_name = Paradox
email_replyto = noreply@domain.com
email_sender = SmtpEmailSender
email_subject_prefix = __default__
ldap_bind_dn = cn=ldaplookup,cn=Users,dc=domain,dc=com
ldap_bind_pw = ***
ldap_email_attr_name = mail
ldap_search_base = ou=Sites,dc=domain,dc=com
ldap_search_filter = userPrincipalName
ldap_start_tls = false
ldap_uri = ldap://ldapauth.domain.com
smtp_always_cc = Ramy.Mahmoud@domain.com, support@domain.com
smtp_default_domain = domain.com
smtp_password = 
smtp_port = 25
smtp_replyto = no-reply@domain.com
smtp_server = hero.uk.domain.com
smtp_subject_prefix = __default__
smtp_user = 
use_public_cc = true
use_short_addr = false
use_tls = false


[notification]
email_address_resolvers = SessionEmailResolver, LdapEmailResolver
email_enabled = true
email_sender = SmtpEmailSender
smtp_enabled = true
smtp_from = trac@domain.com
smtp_from_author = Paradox
smtp_from_name = Paradox
smtp_password = 
smtp_port = 25
smtp_replyto = no-reply@domain.com
smtp_server = hero.uk.domain.com
smtp_subject_prefix = __default__
smtp_user = 
use_public_cc = true
smtp_always_cc = Ramy.Mahmoud@domain.com, support@domain.com

I hacked notification.py to make it work. attached is diff.

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

Changed 10 years ago by shorif2000

Attachment: trac_ldap_email - Copy.diff added

notification.py under trac

comment:6 Changed 10 years ago by Ryan J Ollos

Please use the unified diff format for patches, as described in trac:TracDev/SubmittingPatches.

comment:7 in reply to:  5 Changed 10 years ago by Steffen Hoffmann

Replying to shorif2000:

This is not working for me on trac 1.01. for trac 0.12 i created a plugin. any suggestions to get this working for trac 1.01?

Wait a moment. You're a bit too fast for me. You claim (plugin) "not working with Trac 1.0.1", but in next sentence you switch to Trac 0.12 and show a Python2.4 issue to us in SO question(s).

Your configuration is a bit fuzzy too. You should disregard any setting in [notification] while using announcer.

comment:8 Changed 10 years ago by shorif2000

I used your patch for trac 1.01. However I could not get it to work. Can you give some instructions?

comment:9 Changed 9 years ago by shino

Thank you for the patch, it works great. I had to change ldap.SCOPE_ONELEVEL by ldap.SCOPE_SUBTREE in directory.search_s function with my LDAP though. It may be a good idea to make it configurable ?

comment:10 Changed 7 years ago by Ryan J Ollos

Owner: Steffen Hoffmann deleted

comment:11 Changed 4 years ago by Ryan J Ollos

Cc: Ryan J Ollos removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.