IABACPolicies.IndexOf

Syntax

IndexOf(Value: IABACPolicy): Integer;

Parameters

Value. Policy value.

Description

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

Comments

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

Policies indexing starts with zero.

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

Example

To execute the example, make sure that attribute-based access control contains a policies set with two nested policies.

To execute the example, add links to the ABAC and Metabase system assemblies.

Sub Main;
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySet: IABACPolicySet;
    Policies: IABACPolicies;
    Policy: IABACPolicy;
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Lic: Object;
    Index: Integer;
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 policy with the 0 index in the first policies set
    PolicySet := PolicyObject.Policies.Item(0);
    Policies := PolicySet.Policies;
    // Add a policy
    Policy := PolicySet.Policies.Add;
    Policy.Name(LocaleCodeID.Russian) := "Test policy";
    Policy.Id := "POLICY";
    // Get policy index
    Index := Policies.IndexOf(Policy);
    // Display policy name and index in the console
    Debug.WriteLine(Policy.Name(MB.CurrentLocale));
    Debug.WriteLine("Index = " + Index.ToString);
    // Check in license
    Lic := Null;
End Sub Main;

After executing the example the following message is displayed in the console:

Test policy

Index = 2

See also:

IABACPolicies