I am getting this error. it worked fine on trac 1.0.1

[root@cobra domain]# cat SmtpLdapEmailSender.py
from trac.core import *
from trac.config import IntOption, Option
from trac.notification import SmtpEmailSender
#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)



error in log file

2015-01-22 17:21:47,028 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 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to