mirror of https://github.com/jumpserver/jumpserver
[Update] 修复取消 LDAP 同步用户任务失败的问题
parent
fc58906bce
commit
78a7bfbd30
|
@ -117,8 +117,6 @@ class LDAPServerUtil(object):
|
||||||
return search_filter
|
return search_filter
|
||||||
|
|
||||||
def search_user_entries_ou(self, search_ou, paged_cookie=None):
|
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()
|
search_filter = self.get_search_filter()
|
||||||
attributes = list(self.config.attr_map.values())
|
attributes = list(self.config.attr_map.values())
|
||||||
ok = self.connection.search(
|
ok = self.connection.search(
|
||||||
|
@ -136,6 +134,7 @@ class LDAPServerUtil(object):
|
||||||
user_entries = list()
|
user_entries = list()
|
||||||
search_ous = str(self.config.search_ougroup).split('|')
|
search_ous = str(self.config.search_ougroup).split('|')
|
||||||
for search_ou in search_ous:
|
for search_ou in search_ous:
|
||||||
|
logger.info("Search user entries ou: {}".format(search_ou))
|
||||||
self.search_user_entries_ou(search_ou)
|
self.search_user_entries_ou(search_ou)
|
||||||
user_entries.extend(self.connection.entries)
|
user_entries.extend(self.connection.entries)
|
||||||
while self.paged_cookie():
|
while self.paged_cookie():
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from django.conf import settings
|
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 ops.celery.decorator import after_app_ready_start
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from .models import User
|
from .models import User
|
||||||
|
@ -88,6 +91,8 @@ def import_ldap_user_periodic():
|
||||||
if not settings.AUTH_LDAP:
|
if not settings.AUTH_LDAP:
|
||||||
return
|
return
|
||||||
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
||||||
|
task_name = sys._getframe().f_code.co_name
|
||||||
|
disable_celery_periodic_task(task_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
interval = settings.AUTH_LDAP_SYNC_INTERVAL
|
interval = settings.AUTH_LDAP_SYNC_INTERVAL
|
||||||
|
|
Loading…
Reference in New Issue