# Can we set an admin user for a realm that is not master?

**URL:** <https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783>\
**Category:** Miscellanaeous\
**Created:** [October 28, 2021, 2:31pm UTC](https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783 "2021-10-28T14:31:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [October 28, 2021, 2:31pm UTC](https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783/1 "2021-10-28T14:31:37Z")

</div>

Hi all,

Our app is running keycloak from a docker container.  
when we run the keycloak we set up a user named “keycloak-admin” with password 12345 (not really 🙂 ) for the MASTER realm.

after that, we create a new realm named NLS from a realm.json file.  
then we add a user named “nls-admin”

Now, if I understand correctly in order to add more users in the NLS realm only the user “keycloak-admin” can do it

when we go into: http:///auth/admin/master/console/ I can log in with “keycloak-admin” and select the NLS realm and then add as many users as I wish.

my question is - is there a way to allow the “nls-admin” user to also have admin permission for the NLS realm? like the “keycloak-admin” but only for the NLS realm.

cause, in the current status, if I try to log in into http:///auth/admin/NLS/console/ with nls-admin i get a page that says that I don’t have permissions.

just to celebrate why we need it - basically, we set up a realm for our customers today. we want to give them an admin user for the keycloak but only for a specific realm

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 28, 2021, 2:39pm UTC](https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783/2 "2021-10-28T14:39:13Z")

</div>

Of course this is possible, but you have to set the proper roles to your “nls-admin” user.  
You have to assign the “realm-admin” role from the “realm-management” client to your “nls-admin” user. The “realm-admin” role effectively assigns all the other roles to the user. See picture:

 ![image 2021-10-28 um 16.36.25](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/7/7459c26dfede649a141e4dc587d6e39c5b821e58.png)

---

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [October 31, 2021, 8:54am UTC](https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783/3 "2021-10-31T08:54:38Z")

</div>

thx a lot. this is exactly what I was looking for!

a quick (I hope) follow-up question - can we assign this role using scripts (kcadm.sh)?

Today we do the following to assign role and group for the nls-admin:

kcadm.sh add-roles --uusername nls-admin --rolename Administrators -r NLS  
kcadm.sh update users/[nls-admin-id]/groups/$GROUP\_ID -r NLS -s realm=NLS -s userId=[nls-admin-id] -s groupId=$GROUP\_ID -n

is there a detailed source for all kcadm.sh commands?

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 31, 2021, 2:01pm UTC](https://forum.keycloak.org/t/can-we-set-an-admin-user-for-a-realm-that-is-not-master/11783/4 "2021-10-31T14:01:41Z")

</div>

The `kcadm` tool is just a wrapper around the Keycloak Admin REST API and to call the various resources/endpoints. So, basically everthing you do via the admin UI (admin web console), you can also do via `kcadm`. Documentation for the Admin REST API is on the documentation page: [Keycloak - Documentation](https://www.keycloak.org/documentation) (ok, it’s not the best docs, but anyhow…)
