From 138863f520cca6e806ea2a61d9220d626316950e Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 24 May 2023 14:52:20 +0200 Subject: [PATCH] Better defining mail filter for existing entries with mail attributes --- lib/pp_admintools/app/barracuda_sync.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/pp_admintools/app/barracuda_sync.py b/lib/pp_admintools/app/barracuda_sync.py index 121faae..8b54013 100644 --- a/lib/pp_admintools/app/barracuda_sync.py +++ b/lib/pp_admintools/app/barracuda_sync.py @@ -27,7 +27,7 @@ from ldap3 import BASE from .ldap import BaseLdapApplication from ..xlate import XLATOR -__version__ = '0.8.3' +__version__ = '0.8.4' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -469,7 +469,17 @@ class BarracudaSyncApp(BaseLdapApplication): self.ldap_mail_dns = {} inst = self.ldap_instances[0] - ldap_filter = '(|(mail=*)(mailAlternateAddress=*)(mailEquivalentAddress=*))' + ldap_filter = ( + '(&(|' + '(objectClass=inetLocalMailRecipient)' + '(objectClass=inetMailGroup)' + '(objectclass=inetMailUser)' + ')(|' + '(mail=*)' + '(mailAlternateAddress=*)' + '(mailEquivalentAddress=*)' + '))' + ) attributes = ['dn', 'mail', 'mailAlternateAddress', 'mailEquivalentAddress'] result = self.get_all_entries(inst, ldap_filter=ldap_filter, attributes=attributes) @@ -501,9 +511,9 @@ class BarracudaSyncApp(BaseLdapApplication): if dn not in self.ldap_mail_dns[mail]: self.ldap_mail_dns[mail].append(dn) - if self.verbose > 2: - msg = _('LDAP Barracuda:') - msg += '\n' + pp(result) + if self.verbose > 1: + msg = _('LDAP entries with mail attributes except them for Barracuda:') + msg += '\n' + pp(self.ldap_mail_dns) LOG.debug(msg) # ------------------------------------------------------------------------- -- 2.39.5