]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Better defining mail filter for existing entries with mail attributes
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 May 2023 12:52:20 +0000 (14:52 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 May 2023 12:52:20 +0000 (14:52 +0200)
lib/pp_admintools/app/barracuda_sync.py

index 121faae5b4c29561989d89f4d0eb31a778415e8a..8b540133b625c3eebe2928dac2135d70b9ca9db3 100644 (file)
@@ -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)
 
     # -------------------------------------------------------------------------