|
|
|
@ -37,7 +37,16 @@ import radicale_auth_ldap.ldap3imports
|
|
|
|
|
class Auth(BaseAuth):
|
|
|
|
|
def is_authenticated(self, user, password):
|
|
|
|
|
"""Check if ``user``/``password`` couple is valid."""
|
|
|
|
|
SERVER = ldap3.Server(self.configuration.get("auth", "ldap_url"))
|
|
|
|
|
servers = self.configuration.get("auth", "ldap_url")
|
|
|
|
|
if ' ' in servers: # Handle for multiple LDAP server defined in ldap_url with space separation
|
|
|
|
|
servers = servers.split(' ')
|
|
|
|
|
self.logger.debug("Multiple servers: %s" % servers)
|
|
|
|
|
SERVER = ldap3.ServerPool(None)
|
|
|
|
|
for s in servers:
|
|
|
|
|
SERVER.add(ldap3.Server(s))
|
|
|
|
|
else: # only one server is defined
|
|
|
|
|
self.logger.debug("Single server: %s" % servers)
|
|
|
|
|
SERVER = ldap3.Server(servers)
|
|
|
|
|
BASE = self.configuration.get("auth", "ldap_base")
|
|
|
|
|
ATTRIBUTE = self.configuration.get("auth", "ldap_attribute")
|
|
|
|
|
FILTER = self.configuration.get("auth", "ldap_filter")
|
|
|
|
@ -45,7 +54,7 @@ class Auth(BaseAuth):
|
|
|
|
|
PASSWORD = self.configuration.get("auth", "ldap_password")
|
|
|
|
|
SCOPE = self.configuration.get("auth", "ldap_scope")
|
|
|
|
|
SUPPORT_EXTENDED = self.configuration.getboolean("auth", "ldap_support_extended", fallback=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if BINDDN and PASSWORD:
|
|
|
|
|
conn = ldap3.Connection(SERVER, BINDDN, PASSWORD)
|
|
|
|
|
else:
|
|
|
|
|