11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

$ROLESSET $ROLESYou can use the SET command to change the Added Roles part of the list contained in$ROLES. Setting $ROLES only alters a process' Added Roles. It can not alter its User Roles.To set $ROLES to a different list of Added Roles is a restricted system capability. However,such restrictions do not apply to setting $ROLES to a null string, which deletes the list ofAdded Roles.A role must be defined before it can be added. You can define a role using the SQL CREATEROLE command. CREATE ROLE does not give any privileges to a role. To assign privilegesto a role use either the SQL GRANT statement, or the System Management Portal interface.NEW $ROLESNEW $ROLES stacks the current values of both $ROLES and $USERNAME. You canuse the NEW command on $ROLES without security restrictions.ExamplesThe following example returns the list of roles for the current process.WRITE $ROLESThe following example first creates the roles Vendor, Sales, and Contractor. It then displaysthe comma-separated list of default roles (which contain both User Roles and Added Roles).The first SET $ROLES replaces the list of Added Roles with the two roles Sales and Contractor.The second SET $ROLES concatenates the Vendor role to the list of Added Roles.The final SET $ROLES sets the Added Roles list to the null string, removing all AddedRoles. The User Roles remain unchanged throughout:CreateRolesDO $SYSTEM.Security.Login("_SYSTEM","SYS")&sql(CREATE ROLE Vendor)&sql(CREATE ROLE Sales)&sql(CREATE ROLE Contractor)IF SQLCODE=0 {WRITE !,"Created new roles"GOTO SetRoles }ELSEIF SQLCODE=-118 {WRITE !,"Role already exists"GOTO SetRoles }ELSE { WRITE !,"CREATE ROLE failed, SQLCODE=",SQLCODE }SetRolesWRITE !,"Initial: ",$ROLESSET $ROLES="Sales,Contractor"WRITE !,"Replaced: ",$ROLESSET $ROLES=$ROLES_",Vendor"WRITE !,"Concatenated: ",$ROLESSET $ROLES=""WRITE !,"Nulled: ",$ROLES<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 445

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!