Commits

Zhang Huangbin committed bee45bc

[ldap] Use sasl_username in ldap query by default, not sender address in From:.

Comments (0)

Files changed (2)

libs/ldaplib/modeler.py

 
         sender = smtp_session_data['sender'].lower()
         recipient = smtp_session_data['recipient'].lower()
+        sasl_username = smtp_session_data['sasl_username'].lower()
 
         plugin_kwargs = {'smtp_session_data': smtp_session_data,
                          'conn': self.conn,
                          'sender_domain': sender.split('@', 1)[-1],
                          'recipient': recipient,
                          'recipient_domain': recipient.split('@', 1)[-1],
-                         'sasl_username': smtp_session_data.get('sasl_username', '').lower(),
+                         'sasl_username': sasl_username,
                          'sender_dn': None,
                          'sender_ldif': None,
                          'recipient_dn': None,
                     and plugin_kwargs['sender_dn'] is None:
                 sender_dn, sender_ldif = conn_utils.get_account_ldif(
                     conn=self.conn,
-                    account=sender,
+                    account=sasl_username,
                     attrlist=sender_search_attrlist,
                 )
                 plugin_kwargs['sender_dn'] = sender_dn

libs/sql/modeler.py

 
         sender = smtp_session_data['sender'].lower()
         recipient = smtp_session_data['recipient'].lower()
+        sasl_username = smtp_session_data['sasl_username'].lower()
 
         plugin_kwargs = {'smtp_session_data': smtp_session_data,
                          'conn': self.cursor,
                          'recipient': recipient,
                          'sender_domain': sender.split('@')[-1],
                          'recipient_domain': recipient.split('@')[-1],
-                         'sasl_username': smtp_session_data.get('sasl_username', '').lower(),
-                        }
+                         'sasl_username': sasl_username}
 
         # TODO Get SQL record of mail user or mail alias before applying plugins
         # TODO Query required sql columns instead of all