Differential D3202 Diff 9163 docker/kolab/utils/patches/0001-Resolve-base_dn-in-kolab_user_base_dn-user_base_dn-a.patch
Changeset View
Changeset View
Standalone View
Standalone View
docker/kolab/utils/patches/0001-Resolve-base_dn-in-kolab_user_base_dn-user_base_dn-a.patch
- This file was added.
From f0a02b4484360617baa434bada6c651b8b0b5d30 Mon Sep 17 00:00:00 2001 | |||||
From: Aleksander Machniak <machniak@kolabsys.com> | |||||
Date: Fri, 1 Oct 2021 15:08:12 +0200 | |||||
Subject: [PATCH 1/2] Resolve %base_dn in kolab_user_base_dn, user_base_dn and | |||||
resource_base_dn | |||||
Reviewers: #pykolab_developers, vanmeeuwen | |||||
Reviewed By: #pykolab_developers, vanmeeuwen | |||||
Subscribers: #pykolab_developers | |||||
Differential Revision: https://git.kolab.org/D2900 | |||||
--- | |||||
pykolab/auth/ldap/__init__.py | 40 ++++++++++++++++++++--------------- | |||||
1 file changed, 23 insertions(+), 17 deletions(-) | |||||
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py | |||||
index 5c8c668..046c30c 100644 | |||||
--- a/pykolab/auth/ldap/__init__.py | |||||
+++ b/pykolab/auth/ldap/__init__.py | |||||
@@ -647,13 +647,7 @@ class LDAP(Base): | |||||
if len(_filter) <= 6: | |||||
return None | |||||
- config_base_dn = self.config_get('resource_base_dn') | |||||
- ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
- | |||||
- if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
- resource_base_dn = ldap_base_dn | |||||
- else: | |||||
- resource_base_dn = config_base_dn | |||||
+ resource_base_dn = self._object_base_dn('resource') | |||||
_results = self.ldap.search_s( | |||||
resource_base_dn, | |||||
@@ -801,13 +795,7 @@ class LDAP(Base): | |||||
if len(_filter) <= 6: | |||||
return None | |||||
- config_base_dn = self.config_get('resource_base_dn') | |||||
- ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
- | |||||
- if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
- resource_base_dn = ldap_base_dn | |||||
- else: | |||||
- resource_base_dn = config_base_dn | |||||
+ resource_base_dn = self._object_base_dn('resource') | |||||
_results = self.ldap.search_s( | |||||
resource_base_dn, | |||||
@@ -2470,9 +2458,7 @@ class LDAP(Base): | |||||
conf_prefix = 'kolab_' if kolabuser else '' | |||||
- user_base_dn = self.config_get(conf_prefix + 'user_base_dn') | |||||
- if user_base_dn is None: | |||||
- user_base_dn = self.config_get('base_dn') | |||||
+ user_base_dn = self._object_base_dn('user', conf_prefix) | |||||
auth_attrs = self.config_get_list('auth_attributes') | |||||
@@ -2684,6 +2670,26 @@ class LDAP(Base): | |||||
return domains | |||||
+ def _object_base_dn(self, objectType, prefix=''): | |||||
+ """ | |||||
+ Get configured base DN for specified Kolab object type | |||||
+ """ | |||||
+ object_base_dn = self.config_get(prefix + objectType + '_base_dn') | |||||
+ config_base_dn = self.config_get('base_dn') | |||||
+ ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
+ | |||||
+ if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
+ base_dn = ldap_base_dn | |||||
+ else: | |||||
+ base_dn = config_base_dn | |||||
+ | |||||
+ if object_base_dn is None: | |||||
+ object_base_dn = base_dn | |||||
+ else: | |||||
+ object_base_dn = object_base_dn % ({'base_dn': base_dn}) | |||||
+ | |||||
+ return object_base_dn | |||||
+ | |||||
def _synchronize_callback(self, *args, **kw): | |||||
""" | |||||
Determine the characteristics of the callback being placed, and | |||||
-- | |||||
2.33.1 | |||||