Browse Source

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
commit
d2dd487e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/settings/utils/ldap.py
  2. 10
      apps/users/tasks.py

4
apps/settings/utils/ldap.py

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

10
apps/users/tasks.py

@ -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…
Cancel
Save