diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 35bd3ac867..b94eca461e 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -70,12 +70,16 @@ public class AuthServer implements AuthApi { DataEaseException.throwException(validateResult.getMsg()); } XpackLdapUserEntity ldapUserEntity = validateResult.getData(); - LdapAddRequest ldapAddRequest = new LdapAddRequest(); - ldapAddRequest.setUsers(new ArrayList(){{add(ldapUserEntity);}}); - ldapAddRequest.setEnabled(1L); - ldapAddRequest.setDeptId(1L); - ldapAddRequest.setRoleIds(new ArrayList(){{add(2L);}}); - sysUserService.saveLdapUsers(ldapAddRequest); + SysUserEntity user = authUserService.getUserByName(username); + if(ObjectUtils.isEmpty(user) || ObjectUtils.isEmpty(user.getUserId())) { + LdapAddRequest ldapAddRequest = new LdapAddRequest(); + ldapAddRequest.setUsers(new ArrayList(){{add(ldapUserEntity);}}); + ldapAddRequest.setEnabled(1L); + ldapAddRequest.setDeptId(1L); + ldapAddRequest.setRoleIds(new ArrayList(){{add(2L);}}); + sysUserService.saveLdapUsers(ldapAddRequest); + } + username = validateResult.getData().getUserName(); } // 增加ldap登录方式