Hello

I have had trouble ove rthe past configuring this but managed using hacks.

What i want to do is get trac to send emails to users lookup it up through 
AD. 

I am have just upgraded to trac 1.0.3 and my custom hack is broken.


my current setup.


in apache:


Alias /trac "/opt/html/trac"
<Directory /opt/html/trac>
        AuthType Kerberos
        AuthName KerberosLogin
        KrbServiceName HTTP/intranet.domain.com
        KrbMethodNegotiate On
        KrbMethodK5Passwd On
        KrbAuthRealms DOMAIN.COM
        Krb5KeyTab /etc/httpd/conf/intranet.keytab

        AuthLDAPURL 
ldap://ldapauth.domain.com/ou=TechSupport,ou=Woking,ou=Sites,dc=domain,dc=com?userPrincipalName
        AuthLDAPBindDN cn=ldaplookup,cn=Users,dc=domain,dc=com
        AuthLDAPBindPassword ****

        require valid-user
        ErrorDocument 401 "<html><meta http-equiv=\"refresh\" 
content=\"0;url=/intranet/info/unauthorized\"></html>"
</Directory>

<Location /trac/paradox>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /opt/html/trac/paradox
   PythonOption TracUriRoot /trac/paradox
</Location>


When a user logs into trac project they are logged in as.

fir...@domain.com


current trac config

[root@cobra trac]# cat /opt/html/trac/paradox/conf/trac.ini
# -*- coding: utf-8 -*-

[announcer]
email_sender = SmtpLdapEmailSender

[attachment]
max_size = 5242880
max_zip_size = 5242880
render_unsafe_content = true

[browser]
color_scale = True
downloadable_paths = /trunk, /branches/*, /tags/*
hide_properties = svk:merge
intermediate_color = 
intermediate_point = 
newest_color = (255, 136, 136)
oldest_color = (136, 136, 255)
oneliner_properties = trac:summary
render_unsafe_content = true
wiki_properties = trac:description

[changeset]
max_diff_bytes = 10000000
max_diff_files = 0
wiki_format_messages = true

[components]
advancedworkflow.controller.ticketworkflowopownercomponent = enabled
advancedworkflow.controller.ticketworkflowopxref = enabled
announcer.api.announcementsystem = disabled
announcer.api.subscriptionresolver = disabled
announcer.distributors.mail.emaildistributor = disabled
announcer.distributors.mail.sendmailemailsender = disabled
announcer.distributors.mail.smtpemailsender = disabled
announcer.email_decorators.announceremaildecorator = disabled
announcer.email_decorators.staticemaildecorator = disabled
announcer.email_decorators.threadingemaildecorator = disabled
announcer.email_decorators.ticketaddlheaderemaildecorator = disabled
announcer.email_decorators.ticketsubjectemaildecorator = disabled
announcer.email_decorators.wikisubjectemaildecorator = disabled
announcer.filters.defaultpermissionfilter = disabled
announcer.formatters.ticketformatter = disabled
announcer.formatters.wikiformatter = disabled
announcer.opt.subscribers.allticketsubscriber = disabled
announcer.opt.subscribers.generalwikisubscriber = disabled
announcer.opt.subscribers.joinablegroupsubscriber = disabled
announcer.opt.subscribers.ticketcomponentownersubscriber = disabled
announcer.opt.subscribers.ticketcomponentsubscriber = disabled
announcer.opt.subscribers.ticketcustomfieldsubscriber = disabled
announcer.opt.subscribers.userchangesubscriber = disabled
announcer.opt.subscribers.watchsubscriber = disabled
announcer.pref.announcerpreferences = disabled
announcer.pref.subscriptionmanagementpanel = disabled
announcer.producers.attachmentchangeproducer = disabled
announcer.producers.ticketchangeproducer = disabled
announcer.producers.wikichangeproducer = disabled
announcer.resolvers.defaultdomainemailresolver = disabled
announcer.resolvers.ldapemailresolver = disabled
announcer.resolvers.sessionemailresolver = disabled
announcer.resolvers.specifiedemailresolver = disabled
announcer.resolvers.specifiedxmppresolver = disabled
announcer.subscribers.carboncopysubscriber = disabled
announcer.subscribers.ticketownersubscriber = disabled
announcer.subscribers.ticketreportersubscriber = disabled
announcer.subscribers.ticketupdatersubscriber = disabled
changelog.changelogmacro.changelogmacro = enabled
changelogmacro.* = enabled
spectrum.smtpldapemailsender.smtpldapemailsender = enabled
ticketchangesets.* = enabled
ticketlog.* = enabled
trac.db.mysql_backend.mysqlconnector = disabled
trac.db.postgres_backend.postgresqlconnector = disabled
tracbacks.tracbacks.tracbacksplugin = enabled
tracdragdrop.* = enabled
tracduplicates.web_ui = enabled
tracopt.mimeview.enscript.enscriptrenderer = enabled
tracopt.mimeview.php.phprenderer = enabled
tracopt.ticket.clone.ticketclonebutton = enabled
tracopt.ticket.commit_updater.committicketreferencemacro = enabled
tracopt.ticket.commit_updater.committicketupdater = enabled
tracopt.ticket.deleter.ticketdeleter = enabled
tracopt.versioncontrol.svn.svn_fs.subversionconnector = enabled
tracopt.versioncontrol.svn.svn_prop.subversionmergepropertydiffrenderer = 
enabled
tracopt.versioncontrol.svn.svn_prop.subversionmergepropertyrenderer = 
enabled
tracopt.versioncontrol.svn.svn_prop.subversionpropertyrenderer = enabled
tracworkflowadmin.web_ui.tracworkflowadminmodule = enabled

[header_logo]
alt = 
link = http://intranet/trac/paradox/
src = common/trac_banner.png

[logging]
log_level = WARNING
log_type = file

[notification]
always_notify_owner = true
always_notify_reporter = true
always_notify_updater = true
email_sender = SmtpEmailSender
smtp_always_cc = sid_supp...@domain.com
smtp_enabled = true
smtp_from = t...@domain.com
smtp_from_author = Paradox
smtp_from_name = Paradox
smtp_password = 
smtp_port = 25
smtp_replyto = no-re...@domain.com
smtp_server = hero.uk.domain.com
smtp_subject_prefix = __default__
smtp_user = 
use_public_cc = true

[project]
descr = Paradox replacement
name = Paradox
url = http://intranet/sidb

[ticket]
commit_ticket_update_check_perms = true
commit_ticket_update_commands.close = 
commit_ticket_update_commands.refs = <ALL>
commit_ticket_update_envelope = []
commit_ticket_update_notify = true
default_component = other
default_milestone = Misc
default_version = v16.6
workflow = 
ConfigurableTicketWorkflow,TicketWorkflowOpOwnerComponent,TicketWorkflowOpXRef

[ticket-changesets]
collapsed = false
commands.close = close closed closes fix fixed fixes
commands.refs = addresses re references refs see
compact = true
envelope = 
hide_when_none = false
notify = true
ticket_comments = false

[ticket-workflow]
accept = new -> assigned
accept.operations = set_owner_to_self
accept.permissions = TICKET_MODIFY
dup = * -> closed
dup.name = close
dup.operations = set_resolution,xref
dup.set_resolution = duplicate
dup.xref = Ticket %s has been marked as a duplicate of this ticket.
dup.xref_local = Closed as duplicate of %s.
leave = * -> *
leave.default = 1
leave.operations = leave_status
needinfo = * -> needinfo
needinfo.name = Need info
needinfo.operations = set_owner_to_reporter
reassign = new,assigned,reopened -> new
reassign.operations = set_owner
reassign.permissions = TICKET_MODIFY
reopen = closed -> reopened
reopen.operations = del_resolution
reopen.permissions = TICKET_CREATE
resolve = new,assigned,reopened -> closed
resolve.operations = set_resolution
resolve.permissions = TICKET_MODIFY

#resolve_new = needinfo -> closed
#resolve_new.name = resolve
#resolve_new.operations = set_resolution
#resolve_new.permissions = TICKET_MODIFY
#resolve_new.set_resolution = invalid,wontfix,worksforme

[ticketlog]
log_message_maxlength = 100
log_pattern = \s*#%s\s+.*

[trac]
base_url = http://intranet/trac/paradox/
check_auth_ip = true
default_date_format = iso8601
default_language = en_GB
default_timezone = 
metanav = login,logout,settings,help,about
repository_dir = /hero/subversion/paradox

i am using 

[root@cobra trac]# cat /etc/redhat-release 
CentOS release 6.5 (Final)

pythin 2.6

ll /usr/lib/python2.6/site-packages
total 748
drwxr-xr-x  4 root root  4096 Aug 19 12:25 
AdvancedTicketWorkflowPlugin-0.11dev_r13338-py2.6.egg
drwxr-xr-x  4 root root  4096 Jun 20  2014 babel
drwxr-xr-x  2 root root  4096 Jun 20  2014 Babel-0.9.4-py2.6.egg-info
drwxr-xr-x  4 root root  4096 Sep 16 16:49 
ChangeLogMacro-0.2_r13850-py2.6.egg
drwxr-xr-x  2 root root  4096 Jun 20  2014 distribute-0.6.10-py2.6.egg-info
-rw-r--r--  1 root root   579 Jan 21 11:39 easy-install.pth
-rw-r--r--  1 root root   126 Nov 12  2010 easy_install.py
-rw-r--r--  2 root root   317 Nov 12  2010 easy_install.pyc
-rw-r--r--  2 root root   317 Nov 12  2010 easy_install.pyo
drwxr-xr-x  4 root root  4096 Jun 20  2014 Genshi-0.7-py2.6-linux-x86_64.egg
drwxr-xr-x. 2 root root  4096 Jun 10  2014 iniparse
-rw-r--r--. 1 root root  1085 Aug 17  2010 iniparse-0.3.1-py2.6.egg-info
-rw-r--r--  1 root root  4330 Aug 14  2009 libproxy.py
-rw-r--r--  2 root root  3990 Feb 20  2013 libproxy.pyc
-rw-r--r--  2 root root  3990 Feb 20  2013 libproxy.pyo
drwxr-xr-x  5 root root  4096 Aug 20 12:19 pip
drwxr-xr-x  2 root root  4096 Aug 20 12:19 pip-1.3.1-py2.6.egg-info
-rw-r--r--  1 root root 88196 Nov 12  2010 pkg_resources.py
-rw-r--r--  2 root root 92875 Nov 12  2010 pkg_resources.pyc
-rw-r--r--  2 root root 92875 Nov 12  2010 pkg_resources.pyo
drwxr-xr-x  6 root root  4096 Jun 20  2014 pygments
drwxr-xr-x  2 root root  4096 Jun 20  2014 Pygments-1.1.1-py2.6.egg-info
drwxr-xr-x. 2 root root  4096 Jun 10  2014 rpmUtils
drwxr-xr-x  3 root root  4096 Jun 20  2014 setuptools
-rw-r--r--  1 root root   144 Nov 12  2010 setuptools-0.6c11-py2.6.egg-info
-rw-r--r--  1 root root    33 Aug 19 16:44 setuptools.pth
-rw-r--r--  1 root root  2362 Nov 12  2010 site.py
-rw-r--r--  2 root root  1771 Nov 12  2010 site.pyc
-rw-r--r--  2 root root  1771 Nov 12  2010 site.pyo
-rw-r--r--  1 root root  3068 Aug 21 12:19 
SmtpLdapEmailSender-1.0-py2.7.egg.tar-gz
drwxr-xr-x  5 root root  4096 Jun 20  2014 Trac-1.0.1-py2.6.egg
drwxr-xr-x  5 root root  4096 Jan 21 11:39 Trac-1.0.3-py2.6.egg
drwxr-xr-x  4 root root  4096 Aug 21 11:17 
TracAnnouncer-1.0dev_r13984-py2.6.egg
drwxr-xr-x  4 root root  4096 Aug 20 11:18 Tracbacks-0.2dev_r12197-py2.6.egg
drwxr-xr-x  4 root root  4096 Aug 19 11:39 
TracDragDrop-0.12.0.12_r13613-py2.6.egg
drwxr-xr-x  4 root root  4096 Aug 20 11:20 TracDuplicates-0.11-py2.6.egg
drwxr-xr-x  4 root root  4096 Aug 20 11:05 
TracTicketChangelogPlugin-0.2dev_r13960-py2.6.egg
drwxr-xr-x  4 root root  4096 Jan 21 11:07 
TracWorkflowAdmin-0.12.0.2-py2.6.egg
drwxr-xr-x. 2 root root  4096 Jun 10  2014 urlgrabber
-rw-r--r--. 1 root root  2285 Jul 30  2013 urlgrabber-3.9.1-py2.6.egg-info
-rw-r--r--  1 root root 54516 Aug 15  2013 virtualenv-1.10.1-py2.6.egg-info
-rw-r--r--  1 root root 97379 Aug 15  2013 virtualenv.py
-rw-r--r--  1 root root 82291 Aug 15  2013 virtualenv.pyc
-rw-r--r--  1 root root 81691 Aug 15  2013 virtualenv.pyo
drwxr-xr-x  2 root root  4096 Aug 20 12:54 virtualenv_support
drwxr-xr-x. 2 root root  4096 Jun 10  2014 yum


ll /opt/html/trac/paradox/plugins/
total 16
drwxr-xr-x 7 apache apache 4096 Sep 16 16:34 changelogmacro
drwxr-xr-x 4 apache apache 4096 Aug 21 12:45 
SmtpLdapEmailSender-1.0-py2.7.egg
drwxr-xr-x 4 apache apache 4096 Aug 20 11:17 tracbacksplugin
drwxr-xr-x 4 apache apache 4096 Aug 20 11:05 tracticketchangelogplugin




#cat SmtpLdapEmailSender.py
from trac.core import *
from trac.config import IntOption, Option
from trac.notification import IEmailSender, SmtpEmailSender
import ldap

class SmtpLdapEmailSender(SmtpEmailSender):

    implements(IEmailSender)

    email_ldap_serveruri = Option('notification', 'email_ldap_serveruri', 
'',
                               """AD LDAP Server to use for looking up 
e-mail addresses""")
    email_ldap_port = IntOption('notification', 'email_ldap_port', 389, 
"""AD LDAP Server port""")
    email_ldap_binddn = Option('notification', 'email_ldap_binddn', '',
                               """Bind DN for LDAP lookup. If not given, 
Kerberos auth will be used for current user""")
    email_ldap_bindpw = Option('notification', 'email_ldap_bindpw', '', 
"""Password for non-kerberos auth""")
    email_ldap_basedn = Option('notification', 'email_ldap_basedn', '', 
"""Base DN to use for LDAP searches""")
    
    email_attr = 'mail'
    
    def __init__(self):
        self.log.debug("Initialising LDAP object with URI: ", 
self.email_ldap_serveruri)
        self.ldap_conn=ldap.initialize(self.email_ldap_serveruri)
        
        
    def send(self, from_addr, recipients, message):
        
        if self.email_ldap_binddn != None:
            self.log.info("Binding to LDAP as " + self.email_ldap_binddn)
            self.ldap_conn.bind_s(self.email_ldap_binddn, 
self.email_ldap_bindpw, ldap.AUTH_SIMPLE)
        else:
            self.log.info("Binding to LDAP with Kerberos")
            self.ldap_conn.bind_s()
        
        #Iterate through recipients, checking for correct e-mail addresses 
in LDAP
        #Output in ldapRecipients
        self.log.info("Updating list of recipients")
        new_recipients = []
        for addr in recipients:
            self.log.debug("Searching LDAP server %s for user %s", 
self.email_ldap_serveruri, addr)
            search_string = 'userPrincipalName=' + addr
            result = self.ldap_conn.search_s(self.email_ldap_basedn, 
ldap.SCOPE_SUBTREE, search_string, [self.email_attr])
            
            #result is formatted as a string (result) in a list of [attr 
values], in a dictionary of {attr_name=>attr_values}
            #in a tuple of (DN, Entry), within a list of results. So result 
for principle name jas...@domain.com would be
            #[('CN=Jason 
Aftalion,OU=TechSupport,OU=Woking,OU=Sites,DC=domain,DC=com', {'mail': 
['jason.aftal...@domain.com']})] 
            if result[0][1][self.email_attr][0]:
                self.log.debug("Found e-mail address: " + 
result[0][1][self.email_attr][0])
                new_recipients.append(result[0][1][self.email_attr][0])
            else:
                self.log.debug("Could not find e-mail address")
                new_recipients.append(addr)
            
            
            return super(SmtpLdapEmailSender,self).send(from_addr, 
new_recipients, message)


This was working fine in trac 1.0.1. the error i recieve is

2015-01-22 14:15:24,738 Trac[web_ui] ERROR: Failure sending notification on 
change to ticket #86: ConfigurationError: Cannot find an implementation of 
the <tt>IEmailSender</tt> interface named <tt>SmtpLdapEmailSender</tt>. 
Please check that the Component is enabled or update the option 
<tt>[notification] email_sender</tt> in trac.ini.


-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-dev+unsubscr...@googlegroups.com.
To post to this group, send email to trac-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to