Sorry, I should have given a little more direction. Not enough coffee...
The way you add permissions is not by editing users, but b y editing security policies. You get the policy for the current container using
LABKEY.Security.getPolicy(config)
see
https://www.labkey.org/download/clientapi_docs/javascript-
api/symbols/LABKEY.SecurityPolicy.html
Then you can grant or remove roles to users/groups .
addRoleAssignment(principalId, role)
clearRoleAssignments(principalId)
then use
LABKEY.Security.savePolicy(config)