from .ldap import BaseLdapApplication
from ..xlate import XLATOR
-__version__ = '0.8.4'
+__version__ = '0.8.5'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.ldap_mail_dns = {}
self.aliases_to_create = []
self.aliases_to_remove = []
+ self.aliases_to_modify = []
self.ignore_aliases_res = []
desc = _(
if dn not in self.ldap_mail_dns[mail]:
self.ldap_mail_dns[mail].append(dn)
- if self.verbose > 1:
+ if self.verbose > 2:
msg = _('LDAP entries with mail attributes except them for Barracuda:')
msg += '\n' + pp(self.ldap_mail_dns)
LOG.debug(msg)
+ # -------------------------------------------------------------------------
+ def eval_diffs(self):
+ """Evaluate all entries to create, to change or to modify."""
+ LOG.info(_('Evaluating all LDAP entries to create, to change or to modify.'))
+
+ self.aliases_to_create = []
+ self.aliases_to_remove = []
+ self.aliases_to_modify = []
+
+ for dn in self.ldap_aliases:
+ entry = self.ldap_aliases[dn]
+ do_delete = False
+ entry_in_local_aliases = False
+ for mail in entry['mail']:
+ if mail in self.ldap_mail_dns:
+ do_delete = True
+ break
+ for cn in self.existing_aliases.keys():
+ local_alias = self.existing_aliases[cn]
+ if mail.lower() == local_alias['alias'].lower():
+ entry_in_local_aliases = True
+ if not entry_in_local_aliases:
+ do_delete = True
+ if do_delete:
+ self.aliases_to_remove.append(dn)
+
+ if self.berbose > 1:
+ msg = _('LDAP Entries to remove:') + '\n' + pp(self.aliases_to_remove)
+ LOG.debug(msg)
+
# -------------------------------------------------------------------------
def _run(self):
self.read_virtual_alias_mappings()
self.read_barracuda_ldap_aliases()
self.get_other_ldap_mail_entries()
+ self.eval_diffs()
# =============================================================================