Loading TOC...

sec.protectCollection

sec.protectCollection(
   uri as String,
   permissions as element(sec.permission)[]
) as (Number|String)

Summary

Protects a collection $uri with the given permissions ($permissions). Returns the unique id of the protected collection. If the protected collection at the specified URI does not exist, it is created.

Parameters
uri The URI of a collection.
permissions Permissions governing the collection.

Required Privileges

http://marklogic.com/xdmp/privileges/protect-collection

Usage Notes

If $uri is empty or can not be cast as an xs:AnyURI, an error is raised.

If a collection with the same uri is already protected, an error is raised.

This function must be executed against the security database.

Example


// execute this against the security database

declareUpdate(); 
const sec = require('/MarkLogic/security.xqy');

sec.protectCollection("http://marklogic.com/dev_modules", 
                       [xdmp.permission("Temporary", "read","element"), 
                        xdmp.permission("Temporary", "insert","element")]) 

// Users with the "Developer" role can read and insert files in "dev_modules."  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.