Using XQuery for Query Rolesets
Use the xdmp:database-node-query-rolesets()
helper function with the sec:add-query-rolesets()
command to set up query rolesets using XQuery.
For example:
xquery version "1.0-ml"; import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy"; (: run this against the Security database :) let $qry := 'xdmp:database-node-query-rolesets(fn:doc("/example.xml"), ("all"))' let $qry-rolesets := xdmp:eval($qry, (),<options xmlns="xdmp:eval"> <database>{xdmp:database('Documents')}</database> </options>) return sec:add-query-rolesets($qry-rolesets)
To manually set up just a few query rolesets, use the sec:add-query-rolesets()
command using XQuery.
(: add a few query rolesets => run against the Security database :) xquery version "1.0-ml"; import module namespace sec="http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy"; let $roleset := sec:query-roleset("new-role") return sec:add-query-rolesets(sec:query-rolesets(($roleset))