IABACPolicySets.IndexOf

Syntax

IndexOf(Value: IABACPolicySet): Integer;

IndexOf(Prognoz.Platform.Interop.ABAC.IABACPolicySet): System.Int32;

Parameters

Value. Policies set value.

Description

The IndexOf method returns policies set index in attribute-based access control structure.

Comments

If the specified policies set is not found, the method returns -1.

Policies sets indexing starts with zero.

To get attribute-based access control structure element by its index, use the IABACPolicySets.Item property.

Example

To execute the example, make sure that attribute-based access control contains two policies sets.

To execute the example, add links to the ABAC, Metabase, ForeSystem (for the Fore.NET example) system assemblies.

Sub Main;
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySets: IABACPolicySets;
    PolicySet1, PolicySet2: IABACPolicySet;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
    Index1, Index2: Integer;
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 policies set with the POLICYSET1 identifier
    PolicySets := PolicyObject.Policies;
    PolicySet1 := PolicySets.FindById(
"POLICYSET1");
    
// Get policies set index
    Index1 := PolicySets.IndexOf(PolicySet1);
    
// Display policies set name and index in the console
    Debug.WriteLine(PolicySet1.Name(MB.CurrentLocale));
    Debug.WriteLine(
"Index = " + Index1.ToString);
    
// Get policies set with the POLICYSET2 identifier
    PolicySet2 := PolicySets.FindById("POLICYSET2");
    
// Get policies set index
    Index2 := PolicySets.IndexOf(PolicySet2);
    
// Display policies set name and index in the console   
    Debug.WriteLine(PolicySet2.Name(MB.CurrentLocale));
    Debug.WriteLine(
"Index = " + Index2.ToString);
    
// Check in license
    Lic := Null;
End Sub Main;

Imports Prognoz.Platform.Interop.ABAC;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySets: IABACPolicySets;
    PolicySet1, PolicySet2: IABACPolicySet;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
    Index1, Index2: Integer;
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 policies set with the POLICYSET1 identifier
    PolicySets := PolicyObject.Policies;
    PolicySet1 := PolicySets.FindById(
"POLICYSET1");
    
// Get policies set index
    Index1 := PolicySets.IndexOf(PolicySet1);
    
// Display policies set name and index in the console
    System.Diagnostics.Debug.WriteLine(PolicySet1.Name[MB.CurrentLocale]);
    System.Diagnostics.Debug.WriteLine(
"Index = " + Index1.ToString());
    
// Get policies set with the POLICYSET2 identifier
    PolicySet2 := PolicySets.FindById("POLICYSET2");
    
// Get policies set index
    Index2 := PolicySets.IndexOf(PolicySet2);
    
// Display policies set name and index in the console   
    System.Diagnostics.Debug.WriteLine(PolicySet1.Name[MB.CurrentLocale]);
    System.Diagnostics.Debug.WriteLine(
"Index = " + Index2.ToString());
    
// Check in license
    Lic := Null;
End Sub;

After executing the example the console displays the message:

Test policies set

Index = 0

Test policies set 2

Index = 1

See also:

IABACPolicySets