sec.createUserWithRole( user-name as String, description as String?, password as String, role-names as String[], permissions as element(sec.permission)[], collections as String[], external-names as String[] ) as (Number|String)
Creates a new user in the system database for the context database. Returns the user ID of the created user. Also creates a role by the same name and assigns the newly-created user to the newly-created role. Parameters that define roles, permissions, and collections are only applied to the new user.
http://marklogic.com/xdmp/privileges/create-user
or create-data-user
http://marklogic.com/xdmp/privileges/create-role
or create-data-role
http://marklogic.com/xdmp/privileges/grant-all-roles
orhttp://marklogic.com/xdmp/privileges/grant-my-roles
This function must be executed against the security database.
declareUpdate(); const sec = require('/MarkLogic/security.xqy'); sec.createUserWithRole( "Jim", "Jim the temp", "newtemp", "Temporary", [xdmp.permission("security", "read","element"), xdmp.permission("security", "update","element")], ("http://marklogic.com/dev_modules")) // Creates a new user, named Jim, with the roles, Jim and Temporary. Jim is assigned the default permissions, security(read) and security(update), and the default collection, "http://marklogic.com/dev_modules".