Changeset View
Changeset View
Standalone View
Standalone View
pykolab/auth/ldap/__init__.py
Show First 20 Lines • Show All 814 Lines • ▼ Show 20 Lines | def get_latest_sync_timestamp(self): | ||||
log.debug(_l("Using timestamp %r") % (timestamp), level=8) | log.debug(_l("Using timestamp %r") % (timestamp), level=8) | ||||
return timestamp | return timestamp | ||||
def list_secondary_domains(self): | def list_secondary_domains(self): | ||||
""" | """ | ||||
List alias domain name spaces for the current domain name space. | List alias domain name spaces for the current domain name space. | ||||
""" | """ | ||||
if self.domains is not None: | 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 [] | return [] | ||||
def recipient_policy(self, entry): | def recipient_policy(self, entry): | ||||
""" | """ | ||||
Apply a recipient policy, if configured. | Apply a recipient policy, if configured. | ||||
Given an entry, returns the entry's attribute values to be set. | Given an entry, returns the entry's attribute values to be set. | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def recipient_policy(self, entry): | ||||
want_attrs, | want_attrs, | ||||
entry_dn | entry_dn | ||||
), | ), | ||||
level=8 | level=8 | ||||
) | ) | ||||
attributes = self.get_entry_attributes(entry_dn, want_attrs) | attributes = self.get_entry_attributes(entry_dn, want_attrs) | ||||
for attribute in attributes.keys(): | for attribute in attributes: | ||||
entry[attribute] = attributes[attribute] | entry[attribute] = attributes[attribute] | ||||
if 'preferredlanguage' not in entry: | if 'preferredlanguage' not in entry: | ||||
entry['preferredlanguage'] = conf.get('kolab', 'default_locale') | entry['preferredlanguage'] = conf.get('kolab', 'default_locale') | ||||
# Primary mail address | # Primary mail address | ||||
if primary_mail is not None: | if primary_mail is not None: | ||||
primary_mail_address = conf.plugins.exec_hook( | primary_mail_address = conf.plugins.exec_hook( | ||||
▲ Show 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | def set_entry_attributes(self, entry_id, attributes): | ||||
self._bind() | self._bind() | ||||
entry_dn = self.entry_dn(entry_id) | entry_dn = self.entry_dn(entry_id) | ||||
entry = self.get_entry_attributes(entry_dn, ['*']) | entry = self.get_entry_attributes(entry_dn, ['*']) | ||||
attrs = {} | attrs = {} | ||||
for attribute in attributes.keys(): | for attribute in attributes: | ||||
attrs[attribute.lower()] = attributes[attribute] | attrs[attribute.lower()] = attributes[attribute] | ||||
modlist = [] | modlist = [] | ||||
for attribute, value in attrs.items(): | for attribute, value in attrs.items(): | ||||
if attribute not in entry: | if attribute not in entry: | ||||
entry[attribute] = self.get_entry_attribute(entry_id, attribute) | entry[attribute] = self.get_entry_attribute(entry_id, attribute) | ||||
▲ Show 20 Lines • Show All 1,012 Lines • ▼ Show 20 Lines | def _change_none_user(self, entry, change): | ||||
if result_attribute in entry_changes and old_canon_attr is not None: | if result_attribute in entry_changes and old_canon_attr is not None: | ||||
if not entry_changes[result_attribute] == old_canon_attr: | if not entry_changes[result_attribute] == old_canon_attr: | ||||
self.imap.user_mailbox_rename( | self.imap.user_mailbox_rename( | ||||
old_canon_attr, | old_canon_attr, | ||||
entry_changes[result_attribute] | entry_changes[result_attribute] | ||||
) | ) | ||||
for key in entry_changes.keys(): | for key in entry_changes: | ||||
entry[key] = entry_changes[key] | entry[key] = entry_changes[key] | ||||
self.set_entry_attribute(entry, key, entry[key]) | self.set_entry_attribute(entry, key, entry[key]) | ||||
cache.get_entry(self.domain, entry) | cache.get_entry(self.domain, entry) | ||||
self.imap.connect(domain=self.domain) | self.imap.connect(domain=self.domain) | ||||
server = None | server = None | ||||
▲ Show 20 Lines • Show All 480 Lines • ▼ Show 20 Lines | def _synchronize_callback(self, *args, **kw): | ||||
for entry_dn, entry_attrs in kw['entry']: | for entry_dn, entry_attrs in kw['entry']: | ||||
# This is a referral | # This is a referral | ||||
if entry_dn is None: | if entry_dn is None: | ||||
continue | continue | ||||
entry = {'dn': entry_dn} | entry = {'dn': entry_dn} | ||||
entry_attrs = utils.normalize(entry_attrs) | entry_attrs = utils.normalize(entry_attrs) | ||||
for attr in entry_attrs.keys(): | for attr in entry_attrs: | ||||
entry[attr.lower()] = entry_attrs[attr] | entry[attr.lower()] = entry_attrs[attr] | ||||
# Ignore nstombstone objects | # Ignore nstombstone objects | ||||
if 'objectclass' in entry: | if 'objectclass' in entry: | ||||
if 'nstombstone' in entry['objectclass']: | if 'nstombstone' in entry['objectclass']: | ||||
return None | return None | ||||
unique_attr = self.config_get('unique_attribute').lower() | unique_attr = self.config_get('unique_attribute').lower() | ||||
Show All 9 Lines | def _synchronize_callback(self, *args, **kw): | ||||
eval("self._change_none_%s(entry, None)" % (entry['type'])) | eval("self._change_none_%s(entry, None)" % (entry['type'])) | ||||
# result_attribute = conf.get('cyrus-sasl', 'result_attribute') | # result_attribute = conf.get('cyrus-sasl', 'result_attribute') | ||||
# | # | ||||
# rcpt_addrs = self.recipient_policy(entry) | # rcpt_addrs = self.recipient_policy(entry) | ||||
# | # | ||||
# log.debug(_l("Recipient Addresses: %r") % (rcpt_addrs), level=8) | # 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] | # entry[key] = rcpt_addrs[key] | ||||
# | # | ||||
# cache.get_entry(self.domain, entry) | # cache.get_entry(self.domain, entry) | ||||
# | # | ||||
# self.imap.connect(domain=self.domain) | # self.imap.connect(domain=self.domain) | ||||
# | # | ||||
# if not self.imap.user_mailbox_exists(entry[result_attribute]): | # if not self.imap.user_mailbox_exists(entry[result_attribute]): | ||||
# folder = self.imap.user_mailbox_create( | # folder = self.imap.user_mailbox_create( | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | ): | ||||
if supported_controls is not None and not len(supported_controls) < 1: | if supported_controls is not None and not len(supported_controls) < 1: | ||||
for control_num in [(int)(x) for x in supported_controls]: | for control_num in [(int)(x) for x in supported_controls]: | ||||
self.ldap.supported_controls.append( | self.ldap.supported_controls.append( | ||||
SUPPORTED_LDAP_CONTROLS[control_num]['func'] | SUPPORTED_LDAP_CONTROLS[control_num]['func'] | ||||
) | ) | ||||
if len(self.ldap.supported_controls) < 1: | if len(self.ldap.supported_controls) < 1: | ||||
for control_num in SUPPORTED_LDAP_CONTROLS.keys(): | for control_num in SUPPORTED_LDAP_CONTROLS: | ||||
log.debug( | log.debug( | ||||
_l("Checking for support for %s on %s") % ( | _l("Checking for support for %s on %s") % ( | ||||
SUPPORTED_LDAP_CONTROLS[control_num]['desc'], | SUPPORTED_LDAP_CONTROLS[control_num]['desc'], | ||||
self.domain | self.domain | ||||
), | ), | ||||
level=8 | level=8 | ||||
) | ) | ||||
_search = self.ldap.search_s( | _search = self.ldap.search_s( | ||||
'', | '', | ||||
scope=ldap.SCOPE_BASE, | scope=ldap.SCOPE_BASE, | ||||
attrlist=['supportedControl'] | attrlist=['supportedControl'] | ||||
) | ) | ||||
for (_result, _supported_controls) in _search: | for (_result, _supported_controls) in _search: | ||||
supported_controls = _supported_controls.values()[0] | 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 \ | if SUPPORTED_LDAP_CONTROLS[control_num]['oid'] in \ | ||||
supported_controls: | supported_controls: | ||||
log.debug( | log.debug( | ||||
_l("Found support for %s") % ( | _l("Found support for %s") % ( | ||||
SUPPORTED_LDAP_CONTROLS[control_num]['desc'], | SUPPORTED_LDAP_CONTROLS[control_num]['desc'], | ||||
), | ), | ||||
level=8 | level=8 | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |