summaryrefslogtreecommitdiffstats
path: root/pykolab/auth
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab/auth')
-rw-r--r--pykolab/auth/ldap/__init__.py23
-rw-r--r--pykolab/auth/ldap/syncrepl.py6
2 files changed, 17 insertions, 12 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 046c30c..a2edf12 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -820,7 +820,7 @@ class LDAP(Base):
List alias domain name spaces for the current domain name space.
"""
if self.domains is not None:
- return [s for s in self.domains.keys() if s not in self.domains.values()]
+ return [s for s in self.domains if s not in self.domains.values()]
return []
@@ -923,7 +923,7 @@ class LDAP(Base):
attributes = self.get_entry_attributes(entry_dn, want_attrs)
- for attribute in attributes.keys():
+ for attribute in attributes:
entry[attribute] = attributes[attribute]
if 'preferredlanguage' not in entry:
@@ -1259,7 +1259,7 @@ class LDAP(Base):
attrs = {}
- for attribute in attributes.keys():
+ for attribute in attributes:
attrs[attribute.lower()] = attributes[attribute]
modlist = []
@@ -1723,13 +1723,18 @@ class LDAP(Base):
self.get_entry_attribute(entry, mailserver_attribute)
rcpt_addrs = self.recipient_policy(entry)
+
for key in rcpt_addrs:
entry[key] = rcpt_addrs[key]
if result_attribute not in entry:
+ entry[result_attribute] = self.get_entry_attribute(entry, result_attribute)
return
- if entry[result_attribute] is None:
+ if result_attribute not in entry:
+ return
+
+ if not entry[result_attribute]:
return
if entry[result_attribute] == '':
@@ -2283,7 +2288,7 @@ class LDAP(Base):
entry_changes[result_attribute]
)
- for key in entry_changes.keys():
+ for key in entry_changes:
entry[key] = entry_changes[key]
self.set_entry_attribute(entry, key, entry[key])
@@ -2780,7 +2785,7 @@ class LDAP(Base):
entry = {'dn': entry_dn}
entry_attrs = utils.normalize(entry_attrs)
- for attr in entry_attrs.keys():
+ for attr in entry_attrs:
entry[attr.lower()] = entry_attrs[attr]
# Ignore nstombstone objects
@@ -2806,7 +2811,7 @@ class LDAP(Base):
#
# log.debug(_l("Recipient Addresses: %r") % (rcpt_addrs), level=8)
#
-# for key in rcpt_addrs.keys():
+# for key in rcpt_addrs:
# entry[key] = rcpt_addrs[key]
#
# cache.get_entry(self.domain, entry)
@@ -3135,7 +3140,7 @@ class LDAP(Base):
)
if len(self.ldap.supported_controls) < 1:
- for control_num in SUPPORTED_LDAP_CONTROLS.keys():
+ for control_num in SUPPORTED_LDAP_CONTROLS:
log.debug(
_l("Checking for support for %s on %s") % (
SUPPORTED_LDAP_CONTROLS[control_num]['desc'],
@@ -3152,7 +3157,7 @@ class LDAP(Base):
for (_result, _supported_controls) in _search:
supported_controls = _supported_controls.values()[0]
- for control_num in SUPPORTED_LDAP_CONTROLS.keys():
+ for control_num in SUPPORTED_LDAP_CONTROLS:
if SUPPORTED_LDAP_CONTROLS[control_num]['oid'] in \
supported_controls:
diff --git a/pykolab/auth/ldap/syncrepl.py b/pykolab/auth/ldap/syncrepl.py
index 03ab5ae..6753605 100644
--- a/pykolab/auth/ldap/syncrepl.py
+++ b/pykolab/auth/ldap/syncrepl.py
@@ -17,12 +17,12 @@ class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer):
callback = None
def __init__(self, filename, *args, **kwargs):
- if kwargs.has_key('callback'):
+ if 'callback' in kwargs:
self.callback = kwargs['callback']
del kwargs['callback']
ldap.ldapobject.LDAPObject.__init__(self, *args, **kwargs)
- self.__db = anydbm.open(filename, 'c', 0640)
+ self.__db = anydbm.open(filename, 'c', 0o640)
self.__presentUUIDs = {}
def syncrepl_set_cookie(self,cookie):
@@ -71,7 +71,7 @@ class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer):
if uuids is None:
if refreshDeletes is False:
nonpresent = []
- for uuid in self.__db.keys():
+ for uuid in self.__db:
if uuid == 'cookie': continue
if uuid in self.__presentUUIDs: continue
nonpresent.append(uuid)