AddCopy(Value: IABACPolicy): IABACPolicy;
The AddCopy method adds copies of the specified policy to attribute-based access control structure.
To execute the example, make sure that the attribute-based access control structure contains two policies sets. The first policies set contains an additional nested policy.
Add links to the ABAC and Metabase system assemblies.
Sub UserProc;
Var
PolicyObject: IABACRootPolicyObject;
PolicySet: IABACPolicySet;
Policy: IABACPolicy;
Policies: IABACPolicies;
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 policy in policies set with the 0 index
PolicySet := PolicyObject.Policies.Item(0);
Policy := PolicySet.Policies.Item(0);
// Get policies set with the 1 index
PolicySet := PolicyObject.Policies.Item(1);
Policies := PolicySet.Policies;
// Copy the first policy from policies set with the 0 index to policies set with the 1 index
Policies.AddCopy(Policy);
// Change name of copied policy
Policies.Item(0).Name(MB.CurrentLocale) := "Copied policy";
// Apply changes in security manager
MS.Apply;
// Check in license
Lic := Null;
End Sub UserProc;
After executing the example the existing policy from the policies set with the 0 index and new name is copied to the specified policies set with the 1 index:
See also: