Unable to update User attributes via the REST API

CMK version: Checkmk Managed Services Edition 2.2.0p4
OS version: Debian 10.12

Hi all,

We are currently preparing our migration to CheckMK. For our on-call rotation, we use the custom stand-by attributes set in the CheckMK GUI.

From what I understand from the REST API documentation, It should be possible to update a user’s attribute by getting the user via the API edit the extension array and submit this array to the PUT api.

Below is a rudimentary python script to simulate this:

import requests

res = requests.get("https://cmk.server/master/check_mk/api/1.0/objects/user_config/vancas1", auth=(
	"automation",
	"------"
	))

data = res.json()['extensions']

# Update the stand-by attribute
data['stand-by'] = "1"

res = requests.put("https://cmk.server/master/check_mk/api/1.0/objects/user_config/vancas1", auth=(
	"automation",
	"----"
	), json=data)

print(res.json())

The response from the API seems to not know about our custom user attribute + complains about the Auth type being ldap …

'title': 'Bad Request', 'status': 400, 'detail': 'These fields have problems: auth_option stand-by', 'fields': {'auth_option': {'auth_type': ['Unsupported value: ldap']}, 'stand-by': ['Unknown field.']}}

Any way to make this work? Am I doing something wrong?

1 Like

You cannot edit LDAP users via REST API, only local accounts.

Hi,

If I test this with a local user, I get the same error, but without the LDAP error ofcourse:

{'title': 'Bad Request', 'status': 400, 'detail': 'These fields have problems: stand-by', 'fields': {'stand-by': ['Unknown field.']}}

So it seems custom user attributes are unknown to the REST api?

I’ve done some digging myself in the CheckMK Source @Github. The validation class for CreateUser does contain a def validate_custom_attributes function, but none to be found on the UpdateUser class …

It seems that this is overlooked by the developers when implementing werk REST API: Create users with custom attributes

Previously, this was possible with the HTTP Api (which we tested against a year ago), but this API is removed in version 2.2.0 …

Is there any possibility to see this implemented in the near future?

Maybe @LaMi can shed a light here?

Hi vancas1,

We have already made some changes in this area. You should now be able to update users that have custom attributes via the REST API on v2.2.0p11 or above. Please see werk user_config: allow update of custom user attributes.

Regards
Gavin

1 Like