IABACPolicySets.IndexOf

Syntax

IndexOf(Value: IABACPolicySet): Integer;

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 and Metabase system assemblies.

Sub UserProc;
Var
    PolicyObject: IABACRootPolicyObject;
    PolicySets: IABACPolicySets;
    PolicySet: IABACPolicySet;
    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;
    PolicySets := PolicyObject.Policies;
    // Add a policies set
    PolicySet := PolicyObject.Policies.Add;
    PolicySet.Name(MB.CurrentLocale) := "Test policies set";
    // Get index of policies set
    Index := PolicySets.IndexOf(PolicySet);
    // Display name and index of policies set in the console
    Debug.WriteLine(PolicySet.Name(MB.CurrentLocale));
    Debug.WriteLine("Index = " + Index.ToString);
    // Check in license
    Lic := Null;
End Sub UserProc;

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

Test policies set

Index = 2

See also:

IABACPolicySets