feat: 修改LDAP导入组织问题 (#8111)

Signed-off-by: Jiangjie.Bai <bugatti_it@163.com>

Co-authored-by: BaiJiangJie <bugatti_it@163.com>
pull/8113/head
fit2bot 3 years ago committed by GitHub
parent f1bd4ea91f
commit d2dd487e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -376,7 +376,9 @@ class LDAPImportUtil(object):
except Exception as e:
errors.append({user['username']: str(e)})
logger.error(e)
if org and org.is_root():
if not org:
return
if org.is_root():
return
for obj in objs:
org.add_member(obj)

@ -81,8 +81,14 @@ def import_ldap_user():
util_server = LDAPServerUtil()
util_import = LDAPImportUtil()
users = util_server.search()
if settings.XPACK_ENABLED:
org_id = settings.AUTH_LDAP_SYNC_ORG_ID
org = Organization.get_instance(org_id)
default_org = None
else:
# 社区版默认导入Default组织
org_id = Organization.DEFAULT_ID
default_org = Organization.default()
org = Organization.get_instance(org_id, default=default_org)
errors = util_import.perform_import(users, org)
if errors:
logger.error("Imported LDAP users errors: {}".format(errors))

Loading…
Cancel
Save