]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Get virtual aliases for Barracuda from LDAP.
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 May 2023 12:14:26 +0000 (14:14 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 May 2023 12:14:26 +0000 (14:14 +0200)
lib/pp_admintools/app/barracuda_sync.py

index 6279e9f8bc644c7e04a4762b7063327084619569..ea5cc4be9c013c21b85e163835aba7b4a936aa51 100644 (file)
@@ -27,7 +27,7 @@ from ldap3 import BASE
 from .ldap import BaseLdapApplication
 from ..xlate import XLATOR
 
-__version__ = '0.8.1'
+__version__ = '0.8.2'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -372,7 +372,7 @@ class BarracudaSyncApp(BaseLdapApplication):
         for mapping in self.virtalias_mappings:
             self.read_virtual_alias_mapping(mapping)
 
-        if self.verbose > 1:
+        if self.verbose > 2:
             msg = _('Evaluated static virtual aliases:')
             msg += '\n' + pp(self.existing_aliases)
             LOG.debug(msg)
@@ -440,11 +440,32 @@ class BarracudaSyncApp(BaseLdapApplication):
             c=self.barracuda_base_dn, i=inst)
         LOG.debug(msg)
 
+    # -------------------------------------------------------------------------
+    def read_barracuda_ldap_aliases(self):
+        """Read all virtual aliases in LDAP below the Barracuda container."""
+        msg = _(
+            'Read all virtual aliases in LDAP below the Barracuda container {!r} ...').format(
+            self.barracuda_base_dn)
+        LOG.info(msg)
+
+        inst = self.ldap_instances[0]
+        ldap_filter = '(&(objectclass=mailRecipient)(mail=*))'
+        base_dn = self.barracuda_base_dn
+        result = self.get_all_entries(inst, ldap_filter=ldap_filter, base_dn=base_dn)
+
+        if self.verbose > 1:
+            msg = _('Virtual aliases in LDAP for Barracuda:')
+            msg += '\n' + pp(result)
+            LOG.debug(msg)
+
+        self.ldap_aliases = result
+
     # -------------------------------------------------------------------------
     def _run(self):
 
         self.verify_barracuda_container()
         self.read_virtual_alias_mappings()
+        self.read_barracuda_ldap_aliases()
 
 
 # =============================================================================