sec.protectPath( path as String, path-namespaces as element(sec.pathNamespace)[], permissions as element(sec.permission)[], path-set as String? ) as (Number|String)
This function protects the path specified, restricting the ability to view content based on the user's permissions. The function returns the unique ID of the protected path.
http://marklogic.com/xdmp/privileges/protect-path
This function must be executed against the Security database.
If the protected path has a path set, it can only have read permissions.
Compartmented-roles in protected paths from the same set should belong to the same compartment.
(: execute this against the Security database :) declareUpdate(); const sec = require('/MarkLogic/security'); sec.protectPath("/root/bar[@baz=1]", [], [xdmp.permission("els-role-2", "read", "element")]); sec.protectPath("test", [], [xdmp.permission("els-role-2", "read", "element")], "set1"); sec.protectPath("/root/reg[fn:matches(@expr, 'is')]", [], [xdmp.permission("els-role-2", "read", "element")])
(: execute this against the Security database :) declareUpdate(); const sec = require('/MarkLogic/security'); sec.protectPath("/root/ml:bar[@baz=1]", [sec.securityPathNamespace("ml", "marklogic.com")], [xdmp.permission("els-role-2", "read", "element")]) (: adds a protected path for the element in the ml namespace :)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.