IABACRules.AddCopy

Syntax

AddCopy(Value: IABACRule): IABACRule;

AddCopy(Prognoz.Platform.Interop.ABAC.IABACRule): Prognoz.Platform.Interop.ABAC.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, Metabase, ForeSystem (for the Fore.NET example) 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 work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    
// Get attribute-based access control structure
    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 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;

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: IABACPolicySet;
    Policy: IABACPolicy;
    Rule: IABACRule;
    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 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 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;

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

See also:

IABACRules