mirror of https://github.com/jumpserver/jumpserver
feat: 修改LDAP导入组织问题 (#8111)
Signed-off-by: Jiangjie.Bai <bugatti_it@163.com> Co-authored-by: BaiJiangJie <bugatti_it@163.com>pull/8113/head
parent
f1bd4ea91f
commit
d2dd487e2c
|
@ -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()
|
||||
org_id = settings.AUTH_LDAP_SYNC_ORG_ID
|
||||
org = Organization.get_instance(org_id)
|
||||
if settings.XPACK_ENABLED:
|
||||
org_id = settings.AUTH_LDAP_SYNC_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…
Reference in New Issue