Skip to content

Commit

Permalink
Fix LDAP configuration check
Browse files Browse the repository at this point in the history
- Fix templates not loaded before checking
- Fix filter fix not applied when checking
  • Loading branch information
juliaschroeder committed Oct 15, 2021
1 parent 78230f8 commit a2f660e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/__init__.py
Expand Up @@ -7,7 +7,7 @@

apiSpec = None # API specification
apiVersion = None # API specification version. Extracted from the OpenAPI document.
backendVersion = "1.3.12" # Backend version number
backendVersion = "1.3.13" # Backend version number


def _loadOpenApiSpec():
Expand Down
9 changes: 5 additions & 4 deletions services/ldap.py
Expand Up @@ -60,10 +60,6 @@ def __init__(self, config=None):
except Exception as err:
msg = " - ".join(str(arg) for arg in err.args) or type(err).__name__
raise ServiceUnavailableError("Failed to connect to server: "+msg)
if "filter" in self._config["users"]:
f = self._config["users"]["filter"]
if f is not None and len(f) != 0 and f[0] != "(" and f[-1] != ")":
self._config["users"]["filter"] = "("+f+")"
if "defaultQuota" in self._config["users"]:
self._defaultProps = {prop: self._config["users"]["defaultQuota"] for prop in
("storagequotalimit", "prohibitsendquota", "prohibitreceivequota")}
Expand All @@ -83,6 +79,10 @@ def _checkConfig(cls, config):
raise KeyError("Missing required config value '{}'".format(cls._configMap.get(required, "user."+required)))
_templatesEnabled = config["users"].get("templates", [])
userAttributes = {}
if "filter" in config["users"]:
f = config["users"]["filter"]
if f is not None and len(f) != 0 and f[0] != "(" and f[-1] != ")":
config["users"]["filter"] = "("+f+")"
for _template in _templatesEnabled:
if _template not in cls._templates:
raise ValueError("Unknown template '{}'".format(_template))
Expand Down Expand Up @@ -378,6 +378,7 @@ def searchUsers(self, query, domains=None, limit=25):

@classmethod
def testConfig(cls, config):
cls.init()
try:
cls._checkConfig(config)
cls.testConnection(config)
Expand Down

0 comments on commit a2f660e

Please sign in to comment.