Skip to main content

Securing MarkLogic Server

Create Roles

Sammy sets up some roles: region-APAC, region-EMEA, and region-NA.

xquery version "1.0-ml";
import module namespace sec="http://marklogic.com/xdmp/security" at   "/MarkLogic/security.xqy";

sec:create-role("can-read", "General read", (), (), ()),
sec:create-role("region-APAC", "Can see APAC documents.",
   (), (), (), (), (), 
   map:map()=>map:with(
     "read", cts:element-query(xs:QName("metadata"), cts:element-word-query(xs:QName("region"), "APAC")))
),
sec:create-role("region-EMEA", "Can see EMEA documents.", 
   (  ), (), (), (), (), 
   map:map()=>map:with(
     "read", cts:element-query(xs:QName("metadata"), cts:element-word-query(xs:QName("region"), "EMEA")))
),
sec:create-role("region-NA", "Can see NA documents.",
   (), (), (), (), (), 
   map:map()=>map:with(
     "read", cts:element-query(xs:QName("metadata"), cts:element-word-query(xs:QName("region"), "NA")))
)