Enonic version: 6.15.8
Hi!
I’m running a job where I need to add users as members of a group (in XP6). I found the authLib.addMembers function in https://repo.enonic.com/public/com/enonic/xp/docs/6.15.8/docs-6.15.8-libdoc.zip!/module-auth.html#.addMembers
and tried using it like this:
In the /resources/jobs/jobs.xml i have:
<jobs>
<job name="sync-job" cron="0 * * * *"/>
</jobs>
where /resources/jobs/sync-job.es6 is:
const syncLib = require("../lib/syncJob/syncJob");
exports.run = () => {
syncLib.syncjobFunction();
};
and /lib/syncJob/syncJob is
const libs = {
authutilities: require("/lib/authutilities"),
auth: require("/lib/xp/auth")
};
const syncjobFunction = () => {
libs.authutilities.runWithSystemContext(() => {
libs.auth.addMembers("group:oidc:groupId1",
["user:oidc:user.name-1", "user:oidc:user.name-2", "user:oidc:user.name-3"]);
});
};
exports.syncjobFunction = syncjobFunction;
and runWithSystemContext is
const runWithSystemContext = callback => (libs.context.run({
principals: ["role:system.admin"]
}, callback));
First I thought maybe some of the users were not present in the userstore, but after picking users I am confident is in the userstore I am stuck again. The runWithSystemContext was necessary to avoid an error message telling me the group did not exist.
When the job containing the attempt at adding the members is done, I get the following error message:
12:03:10.056 INFO c.e.app.cronjob.runner.JobRunnerImpl - Executed job [no.app.name:sync-job] in 58852 ms
12:03:12.299 WARN graphql.execution.ExecutionStrategy - Exception while fetching datacom.enonic.xp.resource.ResourceProblemException: Error: Invalid field argument keys: The number of keys must be inferior to 100 at com.enonic.xp.resource.ResourceProblemException$Builder.build(ResourceProblemException.java:131) at com.enonic.xp.script.impl.util.ErrorHelper.doHandleException(ErrorHelper.java:54) at com.enonic.xp.script.impl.util.ErrorHelper.handleError(ErrorHelper.java:27) at com.enonic.xp.script.impl.value.FunctionScriptValue.call(FunctionScriptValue.java:41) at com.enonic.lib.graphql.GraphQlBean.lambda$setFieldData$4(GraphQlBean.java:206) at graphql.execution.ExecutionStrategy.resolveField(ExecutionStrategy.java:40) at graphql.execution.SimpleExecutionStrategy.execute(SimpleExecutionStrategy.java:18) at graphql.execution.Execution.executeOperation(Execution.java:58) at graphql.execution.Execution.execute(Execution.java:31) at graphql.GraphQL.execute(GraphQL.java:84) at graphql.GraphQL.execute(GraphQL.java:61) at com.enonic.lib.graphql.GraphQlBean.execute(GraphQlBean.java:258) at jdk.nashorn.internal.scripts.Script$Recompilation$827$2576AAA$graphql.L:1#execute(com.enonic.xp.app.users:/lib/graphql.js:76) at jdk.nashorn.internal.scripts.Script$Recompilation$826$390A$graphql.L:1#L:2#post(com.enonic.xp.app.users:/services/graphql/graphql.js:14)
I also noted that graphql was mentioned in the stack trace, and as I had GraphiQL and Guillotine installed as apps in XP, I also tried to remove them to make sure they were not messing with me, but that did not help either.
Does anyone have an idea of what is happening here, and what I can do to make it work?