I have to modify a bunch of users to give then a group and an attribute. I am creating a script to doir using the CLI.
Something like…
#!/bin/bash
KC_URL=URL
ADMINUSER=ADMIN
ADMIN_PASS=PASSS
REALM=YYYY
USERS="xxx@yyy.com xxx+1@yyy.com xxx+3@yyy.com xxx+test@yyy.com"
./kcadm.sh config credentials --server https://$KC_URL/auth --realm master --user $ADMINUSER --password $ADMIN_PASS
GROUP_ID=$(./kcadm.sh get groups -r $REALM |jq -c '.[] |select (.name == "GROUP_XXX")'|jq -r '.id')
echo "Actualizaciones para el grupo $GROUP_ID"
for USER in $USERS; do
echo $USER
USER_ID=$(./kcadm.sh get users -r $REALM -q username=$USER |jq -r -c '.[].id')
echo "Updating $USER_ID"
./kcadm.sh update users/$USER_ID/groups/$GROUP_ID -r $REALM -n
ROLES_AFTER=$(./kcadm.sh get-roles -r $REALM --uusername $USER --effective --fields name)
echo "Updated Roles: $ROLES_AFTER"
echo "Updating sponsor"
./kcadm.sh update users/$USER_ID -r $REALM -s 'attributes.sponsor=XXX'
done
The problem is every command I use with a “-s” parameter returns an error:
“HTTP error - 411 Length Required”
./kcadm.sh update users/UUID/attributes -s “attributes.sponsor=XXX” -r $REALM -n
HTTP error - 411 Length Required
./kcadm.sh update users/UUID/attributes -s “requiredActions=[“VERIFY_EMAIL”]” -r $REALM -n
HTTP error - 411 Length Required
From the docs:
kcadm.sh update users/b544f379-5fc4-49e5-8a8d-5cfb71f46f53/groups/ce01117a-7426-4670-a29a-5c118056fe20 -r demorealm -s realm=demorealm -s userId=b544f379-5fc4-49e5-8a8d-5cfb71f46f53 -s groupId=ce01117a-7426-4670-a29a-5c118056fe20 -n
If I do this it returns the error, but if I do it like this:
./kcadm.sh update users/$USER_ID/groups/$GROUP_ID -r $REALM -n
It works.
I am using KC 14.0.0
I have tested it with a 12.0.4 and the problem does not happen there.
Any idea?