[Update] 修复取消 LDAP 同步用户任务失败的问题

pull/3426/head
BaiJiangJie 5 years ago
parent fc58906bce
commit 78a7bfbd30

@ -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():

@ -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

Loading…
Cancel
Save