Changeset View
Changeset View
Standalone View
Standalone View
pykolab/auth/ldap/__init__.py
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | def authenticate(self, login, realm): | ||||
self._disconnect() | self._disconnect() | ||||
return False | return False | ||||
self._disconnect() | self._disconnect() | ||||
return retval | return retval | ||||
def connect(self, priv=None, immediate=True): | def connect(self, priv=None, immediate=False): | ||||
""" | """ | ||||
Connect to the LDAP server through the uri configured. | Connect to the LDAP server through the uri configured. | ||||
""" | """ | ||||
# Already connected | # Already connected | ||||
if priv is None and self.ldap is not None: | if priv is None and self.ldap is not None: | ||||
return | return | ||||
# Already connected | # Already connected | ||||
Show All 20 Lines | def connect(self, priv=None, immediate=False): | ||||
conn = ldap.ldapobject.ReconnectLDAPObject( | conn = ldap.ldapobject.ReconnectLDAPObject( | ||||
uri, | uri, | ||||
trace_level=trace_level, | trace_level=trace_level, | ||||
retry_max=retry_max, | retry_max=retry_max, | ||||
retry_delay=retry_delay | retry_delay=retry_delay | ||||
) | ) | ||||
if immediate: | |||||
conn.set_option(ldap.OPT_TIMEOUT, 10) | conn.set_option(ldap.OPT_TIMEOUT, 10) | ||||
conn.protocol_version = 3 | conn.protocol_version = 3 | ||||
conn.supported_controls = [] | conn.supported_controls = [] | ||||
if priv is None: | if priv is None: | ||||
self.ldap = conn | self.ldap = conn | ||||
else: | else: | ||||
self.ldap_priv = conn | self.ldap_priv = conn | ||||
▲ Show 20 Lines • Show All 560 Lines • ▼ Show 20 Lines | def recipient_policy(self, entry): | ||||
primary_mail_address.split('@')[0], | primary_mail_address.split('@')[0], | ||||
i, | i, | ||||
primary_mail_address.split('@')[1] | primary_mail_address.split('@')[1] | ||||
) | ) | ||||
primary_mail_address = _primary_mail | primary_mail_address = _primary_mail | ||||
### | ### | ||||
### FIXME | ### FIXME | ||||
Lint: PEP8 E266: too many leading '#' for block comment | |||||
### | ### | ||||
if not primary_mail_address == None: | if not primary_mail_address == None: | ||||
if not entry.has_key(primary_mail_attribute): | if not entry.has_key(primary_mail_attribute): | ||||
self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address) | self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address) | ||||
entry_modifications[primary_mail_attribute] = primary_mail_address | entry_modifications[primary_mail_attribute] = primary_mail_address | ||||
else: | else: | ||||
if not primary_mail_address == entry[primary_mail_attribute]: | if not primary_mail_address == entry[primary_mail_attribute]: | ||||
self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address) | self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address) | ||||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | def user_quota(self, entry_id, folder): | ||||
if not new_quota == current_imap_quota: | if not new_quota == current_imap_quota: | ||||
self.imap.set_quota(folder, new_quota) | self.imap.set_quota(folder, new_quota) | ||||
else: | else: | ||||
if not new_quota == None: | if not new_quota == None: | ||||
self.imap.set_quota(folder, new_quota) | self.imap.set_quota(folder, new_quota) | ||||
### | ### | ||||
### API depth level increasing! | ### API depth level increasing! | ||||
Lint: PEP8 E266 too many leading '#' for block comment Lint: PEP8 E266: too many leading '#' for block comment | |||||
### | ### | ||||
def _bind(self, bind_dn=None, bind_pw=None): | def _bind(self, bind_dn=None, bind_pw=None): | ||||
# If we have no LDAP, we have no previous state. | # If we have no LDAP, we have no previous state. | ||||
if self.ldap is None: | if self.ldap is None: | ||||
self.bind = None | self.bind = None | ||||
self.connect() | self.connect() | ||||
▲ Show 20 Lines • Show All 1,281 Lines • ▼ Show 20 Lines | |||||
# 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( | ||||
# entry[result_attribute] | # entry[result_attribute] | ||||
# ) | # ) | ||||
# | # | ||||
# server = self.imap.user_mailbox_server(folder) | # server = self.imap.user_mailbox_server(folder) | ||||
### | ### | ||||
### Backend search functions | ### Backend search functions | ||||
Lint: PEP8 E266 too many leading '#' for block comment Lint: PEP8 E266: too many leading '#' for block comment | |||||
### | ### | ||||
def _persistent_search(self, | def _persistent_search(self, | ||||
base_dn, | base_dn, | ||||
scope=ldap.SCOPE_SUBTREE, | scope=ldap.SCOPE_SUBTREE, | ||||
filterstr="(objectClass=*)", | filterstr="(objectClass=*)", | ||||
attrlist=None, | attrlist=None, | ||||
attrsonly=0, | attrsonly=0, | ||||
▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines |
too many leading '#' for block comment