Question
· Feb 25, 2017

How to deploy resources and roles?

Hi, Community!

Consider I have ResourceA which is used by role RoleA in dev environment and want to deploy it with the solution on a target system.

Would you please share the best practices to make it?

Thank you in advance!

Discussion (8)0
Log in or sign up to continue

There are many predefined methods defined by Cache under Security.* package to maintain/manage Roles/Users/Resources ...ect.

Specific to your query, you can use below command to export/import Roles:

Write ##class(Security.Roles).Export("C:\RolesExport.xml")
Write ##class(Security.Roles).Import("C:\RolesExport.xml")

Roles: 
Please refer to below class doc for more: http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25sys&CLASSNAME=Security.Roles&CSPCHD=000000000000gt0xiwWBxf8D77QROEE$c2JR50xdHrcUuUzSzc&CSPSHARE=1

Resources:
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25sys&CLASSNAME=Security.Roles&CSPCHD=000000000000gt0xiwWBxf8D77QROEE$c2JR50xdHrcUuUzSzc&CSPSHARE=1

Note that apart from Export and Import options -

If you are using a %Installer Manifest for your deployment (for any environment - test or prod) - you can include in that manifest also the creation of Security elements such as Resources and Roles, etc.

For example:

<Resource
    Name="%accounting_user" 
    Description="Accounting"
    Permission="RW"/>

And:

<Role 
    Name="%DB_USER"
    Description="Database user"
    Resources="MyResource:RW,MyResource1:RWU"
    RolesGranted= />

See more information here (in the docs).

[Defining a Role as part of a manifest is also included in an example in [@Eduard Lebedyuk]'s post here]