@@ -1301,8 +1301,8 @@ public UserAccount createUserAccount(final String userName, final String passwor
13011301 // Check permissions
13021302 checkAccess (getCurrentCallingAccount (), domain );
13031303
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 ) );
13061306 }
13071307
13081308 if (networkDomain != null && networkDomain .length () > 0 ) {
@@ -1489,7 +1489,7 @@ public UserVO createUser(String userName, String password, String firstName, Str
14891489 throw new PermissionDeniedException (String .format ("Account: %s is a system account, can't add a user to it" , account ));
14901490 }
14911491
1492- if (!userAllowMultipleAccounts .valueInDomain ( domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
1492+ if (!userAllowMultipleAccounts .valueInScope ( ConfigKey . Scope . Domain , domainId ) && !_userAccountDao .validateUsernameInDomain (userName , domainId )) {
14931493 throw new CloudRuntimeException ("The user " + userName + " already exists in domain " + domainId );
14941494 }
14951495
@@ -1664,7 +1664,7 @@ protected void validateAndUpdateUsernameIfNeeded(UpdateUserCmd updateUserCmd, Us
16641664 }
16651665
16661666 // 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 ())) {
16681668 assertUserNotAlreadyInDomain (existingUser , newAccount );
16691669 }
16701670
0 commit comments