Changeset View
Changeset View
Standalone View
Standalone View
pykolab/auth/__init__.py
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | def authenticate(self, login): | ||||
return retval | return retval | ||||
def connect(self, domain=None): | def connect(self, domain=None): | ||||
""" | """ | ||||
Connect to the domain authentication backend using domain, or fall | Connect to the domain authentication backend using domain, or fall | ||||
back to the primary domain specified by the configuration. | back to the primary domain specified by the configuration. | ||||
""" | """ | ||||
log.debug(_("Called for domain %r") % (domain), level=9) | log.debug(_("Called for domain %r") % (domain), level=8) | ||||
if not self._auth == None: | if not self._auth == None: | ||||
return | return | ||||
if domain == None: | if domain == None: | ||||
if not self.domain == None: | if not self.domain == None: | ||||
section = self.domain | section = self.domain | ||||
domain = self.domain | domain = self.domain | ||||
else: | else: | ||||
section = 'kolab' | section = 'kolab' | ||||
domain = conf.get('kolab', 'primary_domain') | domain = conf.get('kolab', 'primary_domain') | ||||
else: | else: | ||||
self.list_domains(domain) | self.list_domains(domain) | ||||
section = domain | section = domain | ||||
log.debug( | log.debug( | ||||
_("Using section %s and domain %s") % (section,domain), | _("Using section %s and domain %s") % (section,domain), | ||||
level=9 | level=8 | ||||
) | ) | ||||
if not self.domains == None and self.domains.has_key(domain): | if not self.domains == None and self.domains.has_key(domain): | ||||
section = self.domains[domain] | section = self.domains[domain] | ||||
domain = self.domains[domain] | domain = self.domains[domain] | ||||
log.debug( | log.debug( | ||||
_("Using section %s and domain %s") % (section,domain), | _("Using section %s and domain %s") % (section,domain), | ||||
level=9 | level=8 | ||||
) | ) | ||||
log.debug( | log.debug( | ||||
_("Connecting to Authentication backend for domain %s") % ( | _("Connecting to Authentication backend for domain %s") % ( | ||||
domain | domain | ||||
), | ), | ||||
level=8 | level=8 | ||||
) | ) | ||||
if not conf.has_section(section): | if not conf.has_section(section): | ||||
section = 'kolab' | section = 'kolab' | ||||
if not conf.has_option(section, 'auth_mechanism'): | if not conf.has_option(section, 'auth_mechanism'): | ||||
log.debug( | log.debug( | ||||
_("Section %s has no option 'auth_mechanism'") % (section), | _("Section %s has no option 'auth_mechanism'") % (section), | ||||
level=9 | level=8 | ||||
) | ) | ||||
section = 'kolab' | section = 'kolab' | ||||
else: | else: | ||||
log.debug( | log.debug( | ||||
_("Section %s has auth_mechanism: %r") % ( | _("Section %s has auth_mechanism: %r") % ( | ||||
section, | section, | ||||
conf.get(section,'auth_mechanism') | conf.get(section,'auth_mechanism') | ||||
), | ), | ||||
level=9 | level=8 | ||||
) | ) | ||||
# Get the actual authentication and authorization backend. | # Get the actual authentication and authorization backend. | ||||
if conf.get(section, 'auth_mechanism') == 'ldap': | if conf.get(section, 'auth_mechanism') == 'ldap': | ||||
log.debug(_("Starting LDAP..."), level=9) | log.debug(_("Starting LDAP..."), level=8) | ||||
from pykolab.auth import ldap | from pykolab.auth import ldap | ||||
self._auth = ldap.LDAP(self.domain) | self._auth = ldap.LDAP(self.domain) | ||||
elif conf.get(section, 'auth_mechanism') == 'sql': | elif conf.get(section, 'auth_mechanism') == 'sql': | ||||
from pykolab.auth import sql | from pykolab.auth import sql | ||||
self._auth = sql.SQL(self.domain) | self._auth = sql.SQL(self.domain) | ||||
else: | else: | ||||
log.debug(_("Starting LDAP..."), level=9) | log.debug(_("Starting LDAP..."), level=8) | ||||
from pykolab.auth import ldap | from pykolab.auth import ldap | ||||
self._auth = ldap.LDAP(self.domain) | self._auth = ldap.LDAP(self.domain) | ||||
self._auth.connect() | self._auth.connect() | ||||
def disconnect(self, domain=None): | def disconnect(self, domain=None): | ||||
""" | """ | ||||
Connect to the domain authentication backend using domain, or fall | Connect to the domain authentication backend using domain, or fall | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |