From 6951f4dd97666f15514564283651378f2d357b78 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Fri, 22 Nov 2019 12:25:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E5=88=A0=E9=99=A4=20LDAP=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=97=B6=E6=8A=9B=E5=87=BA=E7=9A=84=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=BC=82=E5=B8=B8=E7=B1=BB=EF=BC=88=20LDAPOU?= =?UTF-8?q?GroupException=EF=BC=89=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=A4=9A?= =?UTF-8?q?=E6=9C=89=20OU=20=E4=B8=8B=E5=AF=BC=E5=85=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/utils/ldap.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/settings/utils/ldap.py b/apps/settings/utils/ldap.py index e5ad1c3e8..041467710 100644 --- a/apps/settings/utils/ldap.py +++ b/apps/settings/utils/ldap.py @@ -21,10 +21,6 @@ __all__ = [ LDAP_USE_CACHE_FLAGS = [1, '1', 'true', 'True', True] -class LDAPOUGroupException(Exception): - pass - - class LDAPConfig(object): def __init__(self, config=None): @@ -119,14 +115,11 @@ class LDAPServerUtil(object): def search_user_entries_ou(self, search_ou, paged_cookie=None): search_filter = self.get_search_filter() attributes = list(self.config.attr_map.values()) - ok = self.connection.search( + self.connection.search( search_base=search_ou, search_filter=search_filter, attributes=attributes, paged_size=self._paged_size, paged_cookie=paged_cookie ) - if not ok: - error = _("Search no entry matched in ou {}".format(search_ou)) - raise LDAPOUGroupException(error) @timeit def search_user_entries(self): From 9e322323f305abd1c33cb017000dac123820ecc2 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Fri, 22 Nov 2019 13:52:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20LDAP=20=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=20cookie=20=E5=8F=96=E5=80=BC=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/utils/ldap.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/settings/utils/ldap.py b/apps/settings/utils/ldap.py index 041467710..726c74c82 100644 --- a/apps/settings/utils/ldap.py +++ b/apps/settings/utils/ldap.py @@ -89,8 +89,12 @@ class LDAPServerUtil(object): def paged_cookie(self): if self._paged_size is None: return None - cookie = self.connection.result['controls']['1.2.840.113556.1.4.319']['value']['cookie'] - return cookie + try: + cookie = self.connection.result['controls']['1.2.840.113556.1.4.319']['value']['cookie'] + return cookie + except Exception as e: + logger.error(e) + return None def get_search_filter_extra(self): extra = ''