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;
    PolicySet: IABACPolicySet;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
    Index: 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;
    PolicySets := PolicyObject.Policies;
    
// Add a policies set
    PolicySet := PolicyObject.Policies.Add;
    PolicySet.Name(MB.CurrentLocale) := 
"Test policies set";
    
// Get policies set index
    Index := PolicySets.IndexOf(PolicySet);
    
// Display policies set name and index in the console
    Debug.WriteLine(PolicySet.Name(MB.CurrentLocale));
    Debug.WriteLine(
"Index = " + Index.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;
    PolicySet: IABACPolicySet;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
    Index: 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;
    PolicySets := PolicyObject.Policies;
    
// Add a policies set
    PolicySet := PolicyObject.Policies.Add();
    PolicySet.Name[MB.CurrentLocale] := 
"Test policies set";
    
// Get policies set index
    Index := PolicySets.IndexOf(PolicySet);
    
// Display policies set name and index in the console
    System.Diagnostics.Debug.WriteLine(PolicySet.Name[MB.CurrentLocale]);
    System.Diagnostics.Debug.WriteLine(
"Index = " + Index.ToString());
    
// Check in license
    Lic := Null;
End Sub;

After executing the example the console displays the message:

Test policies set

Index = 2

See also:

IABACPolicySets