@@ -1301,8 +1301,8 @@ public UserAccount createUserAccount(final String userName, final String passwor
1301
1301
// Check permissions
1302
1302
checkAccess (getCurrentCallingAccount (), domain );
1303
1303
1304
- if (!userAllowMultipleAccounts .valueInDomain ( domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
1305
- throw new CloudRuntimeException ( "The user " + userName + " already exists in domain " + domainId );
1304
+ if (!userAllowMultipleAccounts .valueInScope ( ConfigKey . Scope . Domain , domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
1305
+ throw new InvalidParameterValueException ( String . format ( "The user %s already exists in domain %s" , userName , domain ) );
1306
1306
}
1307
1307
1308
1308
if (networkDomain != null && networkDomain .length () > 0 ) {
@@ -1489,7 +1489,7 @@ public UserVO createUser(String userName, String password, String firstName, Str
1489
1489
throw new PermissionDeniedException (String .format ("Account: %s is a system account, can't add a user to it" , account ));
1490
1490
}
1491
1491
1492
- if (!userAllowMultipleAccounts .valueInDomain ( domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
1492
+ if (!userAllowMultipleAccounts .valueInScope ( ConfigKey . Scope . Domain , domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
1493
1493
throw new CloudRuntimeException ("The user " + userName + " already exists in domain " + domainId );
1494
1494
}
1495
1495
@@ -1664,7 +1664,7 @@ protected void validateAndUpdateUsernameIfNeeded(UpdateUserCmd updateUserCmd, Us
1664
1664
}
1665
1665
1666
1666
// duplicate usernames cannot exist in same domain unless explicitly configured
1667
- if (!userAllowMultipleAccounts .valueInDomain ( newAccount .getDomainId ())) {
1667
+ if (!userAllowMultipleAccounts .valueInScope ( ConfigKey . Scope . Domain , newAccount .getDomainId ())) {
1668
1668
assertUserNotAlreadyInDomain (existingUser , newAccount );
1669
1669
}
1670
1670
0 commit comments