Modify

Opened 9 months ago

Last modified 6 days ago

#11411 new enhancement

Add LDAP E-mail Resolving

Reported by: rnieves Owned by: hasienda
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords: ldap
Cc: rjollos 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 rnieves 9 months ago.
LDAP e-mail resolver patch
trac_ldap_email - Copy.diff (42.9 KB) - added by shorif2000 7 days ago.
notification.py under trac

Download all attachments as: .zip

Change History (10)

Changed 9 months ago by rnieves

LDAP e-mail resolver patch

comment:1 Changed 9 months ago by hasienda

  • Cc rjollos added

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 4 months 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 3 months ago by hasienda

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

comment:4 Changed 8 days ago by hasienda

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

comment:5 follow-up: Changed 7 days 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 7 days ago by rjollos (previous) (diff)

Changed 7 days ago by shorif2000

notification.py under trac

comment:6 Changed 7 days ago by rjollos

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

comment:7 in reply to: ↑ 5 Changed 6 days ago by hasienda

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 6 days ago by shorif2000

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

Add Comment

Modify Ticket

Action
as new .
Author


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

 
Note: See TracTickets for help on using tickets.