Search code examples
jboss

jBoss add-user.bat does not see the new realm


I created a new realm in standalone.xml and now I'm trying to create a new user in that realm. When I use full command like

add-user -a -r realm-name -u user -p password

I get the error:

JBAS015281: The user supplied realm name 'realm-name' does not match the realm name discovered from the property file(s) 'ApplicationRealm'.

When I run just add-user, it promts to choose realm, and there are only applicationrealm and managementrealm in the list.

Here's my snippets from standalone.xml:

1) Domain

<security-domain name="realm-domain" cache-type="default">
    <authentication>
         <login-module code="Remoting" flag="optional">
             <module-option name="password-stacking" value="useFirstPass"/>
         </login-module>
         <login-module code="RealmUsersRoles" flag="required">
             <module-option name="usersProperties" value="${jboss.server.config.dir}/rt-users.properties"/>
             <module-option name="rolesProperties" value="${jboss.server.config.dir}/rt-roles.properties"/>
             <module-option name="realm" value="realm-name"/>
             <module-option name="password-stacking" value="useFirstPass"/>
        </login-module>
    </authentication>
</security-domain>

2) Realm

<security-realm name="realm-name">
   <authentication>
     <local default-user="$local"/>
     <jaas name="realm-domain"/>
   </authentication>
</security-realm>

Solution

  • Copy mgmt-users.properties (or application-users.properties) to for example myfile.properties.

    Change the realm in myfile.properties; edit the line

    #$REALM_NAME=ManagementRealm$ This line is used by the add-user utility ...
    

    to

    #$REALM_NAME=realm-name$ This line is used by the add-user utility ...
    

    Then do

    D:\dev\eap_wildfly\eap-7.4.0>bin\add-user.bat -up standalone\configuration\myfile.properties
    

    and add a username:password as usual.