from .ldap import BaseLdapApplication
from ..xlate import XLATOR
-__version__ = '0.9.6'
+__version__ = '0.9.7'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
for dn in self.ldap_aliases:
entry = self.ldap_aliases[dn]
+ ldap_cn = entry['cn'][0]
do_delete = False
entry_in_local_aliases = False
for mail in entry['mail']:
if mail in self.ldap_mail_dns:
do_delete = True
+ if self.verbose > 2:
+ msg = _(
+ 'Removing {!r}, because there are mail attributes somewhere '
+ 'else.').format(dn)
+ LOG,debug(msg)
break
- for cn in self.existing_aliases.keys():
- local_alias = self.existing_aliases[cn]
- if mail.lower() == local_alias['alias'].lower():
+ for local_cn in self.existing_aliases.keys():
+ if ldap_cn.lower() == local_cn.lower():
entry_in_local_aliases = True
- if not entry_in_local_aliases:
+ if not entry_in_local_aliases and not do_delete:
+ if self.verbose > 2:
+ msg = _(
+ 'Removing {dn!r}, because there is no key {cn!r} in virtual aliases'
+ 'table.').format(dn=dn, cn=local_cn)
+ LOG,debug(msg)
do_delete = True
if do_delete:
self.aliases_to_remove.append(dn)
self.aliases_to_create = []
- for cn in self.existing_aliases.keys():
- local_alias = self.existing_aliases[cn]
+ for local_cn in self.existing_aliases.keys():
+ local_alias = self.existing_aliases[local_cn]
mail = local_alias['alias']
if mail in self.ldap_mail_dns:
do_create = True
for dn in self.ldap_aliases:
entry = self.ldap_aliases[dn]
- if mail in entry['mail']:
+ ldap_cn = entry['cn'][0]
+ if local_cn.lower() == ldap_cn.lower():
do_create = False
break
if do_create:
- self.aliases_to_create.append(cn)
+ self.aliases_to_create.append(local_cn)
self.aliases_to_create.sort(key=str.lower)
self.aliases_to_modify = {}
- for cn in self.existing_aliases.keys():
- local_alias = self.existing_aliases[cn]
+ for local_cn in self.existing_aliases.keys():
+ local_alias = self.existing_aliases[local_cn]
mail = local_alias['alias']
if self.verbose > 3:
- LOG.debug('Evaluating CN {!r} for modifications ...'.format(cn))
+ LOG.debug('Evaluating CN {!r} for modifications ...'.format(local_cn))
if mail in self.ldap_mail_dns:
if self.verbose > 2:
modify_data = None
for dn in self.ldap_aliases:
entry = self.ldap_aliases[dn]
- if mail in entry['mail']:
+ ldap_cn = entry['cn'][0]
+ if ldap_cn.lower() == local_cn.lower():
if self.verbose > 3:
LOG.debug('Evaluating DN {!r} for modifications ...'.format(dn))
- modify_data = self._create_modify_alias_data(cn, entry)
+ modify_data = self._create_modify_alias_data(local_cn, entry)
if modify_data:
self.aliases_to_modify[dn] = modify_data
break