IABACRules.AddCopy

Syntax

AddCopy(Value: IABACRule): IABACRule;

Description

The AddCopy method adds a copy of the specified rule to policy.

Example

To execute the example, make sure that attribute-based access control structure contains two policies. The second policy contains a rule with the RULE identifier.

Add links to the ABAC and Metabase system assemblies.

Sub UserProc;
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySet: IABACPolicySet;
    Policy: IABACPolicy;
    Rule: IABACRule;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    // Get license to be able to work with the security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    // Get attribute-based access control
    PolicyObject := MB.Security.Policy.ABACRules;
    // Get policy with the 1 index in the first policies set  
    PolicySet := PolicyObject.Policies.Item(0);
    Policy := PolicySet.Policies.Item(1);
    // Find rule with the RULE identifier
    Rule := Policy.Rules.FindById("RULE");
    // Get policy with the 0 index
    Policy := PolicySet.Policies.Item(0);
    // Copy the found rule from policy with the 1 index to policy with the 0 index
    Policy.Rules.AddCopy(Rule);
    // Apply changes in security manager
    MS.Apply;
    // Check in license
    Lic := Null;
End Sub UserProc;

After executing the example the existing rule from other policy is copied to the specified attribute-based access control policy.

See also:

IABACRules