From 78a7bfbd30046a3aac14cf1ce392f7ceae807161 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Mon, 11 Nov 2019 18:50:05 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E5=A4=8D=E5=8F=96=E6=B6=88?= =?UTF-8?q?=20LDAP=20=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=A4=B1=E8=B4=A5=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 | 3 +-- apps/users/tasks.py | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/settings/utils/ldap.py b/apps/settings/utils/ldap.py index 3df45bfae..e5ad1c3e8 100644 --- a/apps/settings/utils/ldap.py +++ b/apps/settings/utils/ldap.py @@ -117,8 +117,6 @@ class LDAPServerUtil(object): return search_filter def search_user_entries_ou(self, search_ou, paged_cookie=None): - logger.info("Search user entries ou: {}, paged_cookie: {}". - format(search_ou, paged_cookie)) search_filter = self.get_search_filter() attributes = list(self.config.attr_map.values()) ok = self.connection.search( @@ -136,6 +134,7 @@ class LDAPServerUtil(object): user_entries = list() search_ous = str(self.config.search_ougroup).split('|') for search_ou in search_ous: + logger.info("Search user entries ou: {}".format(search_ou)) self.search_user_entries_ou(search_ou) user_entries.extend(self.connection.entries) while self.paged_cookie(): diff --git a/apps/users/tasks.py b/apps/users/tasks.py index 29355514d..45e1c40cd 100644 --- a/apps/users/tasks.py +++ b/apps/users/tasks.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- # +import sys from celery import shared_task from django.conf import settings -from ops.celery.utils import create_or_update_celery_periodic_tasks +from ops.celery.utils import ( + create_or_update_celery_periodic_tasks, disable_celery_periodic_task +) from ops.celery.decorator import after_app_ready_start from common.utils import get_logger from .models import User @@ -88,6 +91,8 @@ def import_ldap_user_periodic(): if not settings.AUTH_LDAP: return if not settings.AUTH_LDAP_SYNC_IS_PERIODIC: + task_name = sys._getframe().f_code.co_name + disable_celery_periodic_task(task_name) return interval = settings.AUTH_LDAP_SYNC_INTERVAL