IABACPolicySets.AddCopy

Syntax

AddCopy(Value: IABACPolicySet): IABACPolicySet;

Description

The AddCopy method adds a copy of the specified policies set to attribute-based access control structure.

Example

To execute the example, make sure that attribute-based access control structure contains two policies sets. The first policies set contains an additional nested policies set.

Add links to the ABAC and Metabase system assemblies.

Sub UserProc;
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySet, Sets: IABACPolicySet;
    PolicySets: IABACPolicySets;
    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 the first policies set in the policies set with the 0 index
    PolicySet := PolicyObject.Policies.Item(0);
    PolicySets := PolicySet.PolicySets;
    Sets := PolicySets.Item(0);
    // Get policies set with the 1 index
    PolicySet := PolicyObject.Policies.Item(1);
    PolicySets := PolicySet.PolicySets;
    // Copy the first policies set from the policies set with the 0 index to the policies set with the 1 index
    PolicySets.AddCopy(Sets);
    // Rename the copied policies set
    PolicySets.Item(0).Name(MB.CurrentLocale) := "Copied policies set";
    // Apply changes in security manager
    MS.Apply;
    // Check in license
    Lic := Null;
End Sub UserProc;

After executing the example the existing policies set with the 0 index and new name is copied to the specified policies set with the 1 index:

See also:

IABACPolicySets