From: Frank Brehm Date: Wed, 24 May 2023 12:52:20 +0000 (+0200) Subject: Better defining mail filter for existing entries with mail attributes X-Git-Tag: 0.9.0~1^2~26 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=138863f520cca6e806ea2a61d9220d626316950e;p=pixelpark%2Fpp-admin-tools.git Better defining mail filter for existing entries with mail attributes --- 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) # -------------------------------------------------------------------------