AddCopy(Value: IABACPolicySet): IABACPolicySet;
The AddCopy method adds a copy of the specified policies set to attribute-based access control structure.
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, Metabase, ForeSystem (for the Fore.NET example) 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 work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
// Get attribute-based access control structure
PolicyObject := MB.Security.Policy.ABACRules;
// Get the first policies set in 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 policies set with the 0 index to policies set with the 1 index
PolicySets.AddCopy(Sets);
// Change name of 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;
Imports Prognoz.Platform.Interop.ABAC;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
PolicyObject: IABACRootPolicyObject;
PolicySet, Sets: IABACPolicySet;
PolicySets: IABACPolicySets;
MB: IMetabase;
MS: IMetabaseSecurity;
Lic: Object;
Begin
MB := Params.Metabase;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
// Get attribute-based access control structure
PolicyObject := MB.Security.Policy.ABACRules;
// Get the first policies set in 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 policies set with the 0 index to policies set with the 1 index
PolicySets.AddCopy(Sets);
// Change name of 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;
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: