CRecordUserDbGetUserList
Fetches a list of all registered users.
This message belongs to the session manager API.
{ "id": "7921c886-3d67-41a6-b451-b091b3ae092a", "name": "USER_DB_GET_USER_LIST", "description": "Get the user list.", "slots": [ { "key": "SessionToken", "name": "SESSION_TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." }, { "key": "userIds", "name": "USER_IDS", "direction": "ANSWER", "mandatory": "true", "type": "STRING_ARRAY", "description": "An array of user ids." } ] }
Example of use of the class CRecordUserDbGetUserList (after generating)
You need the microservice ID of the session manager:
public static final IId SESSION_MICROSERVICE_ID = CIdFactory.fromObject("ccf168c1-f18b-4229-85f9-24461a19ee6a");
To fetch the user list, we need the token we received when we logged in.
We additionally need the corresponding right to fetch the user list: NY_GetUserList
.
User rights are stored in the user database by the administrator.
private void getUserList(@NotNull final UUID aToken) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordUserDbGetUserList.create(); CRecordUserDbGetUserList.setSessionToken(record, aToken); sendRequest(env, record); }
To catch the response of the request, we need a message handler. We add it in the constructor of the message handler registry.
// constructor: addMessageHandler(CRecordUserDbGetUserList.ID, this::asyncGetUserList);
private boolean asyncGetUserList(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { final UUID token = CRecordUserDbGetUserList.getSessionToken(aRecord, null); final String[] userIds = CRecordUserDbGetUserList.getUserIds(aRecord, null); // ... } return true; } return false; }