IndexOf(Value: IABACRule): Integer;
Value. Rule value.
The IndexOf method returns index of a rule in attribute-based access control policy.
If the specified rule is not found, the method returns -1.
Rules indexing starts with zero.
To get attribute-based access control structure element by its index, use the IABACRules.Item property.
To execute the example, make sure that attribute-based access control contains a policies set with two nested rules.
To execute the example, add links to the ABAC and Metabase system assemblies.
Sub Main;
Var
PolicyObject: IABACRootPolicyObject;
PolicySet: IABACPolicySet;
Policy: IABACPolicy;
Rules: IABACRules;
Rule: IABACRule;
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 1 index in the first policies set
PolicySet := PolicyObject.Policies.Item(0);
Policy := PolicySet.Policies.Item(0);
// Add a rule
Rules := Policy.Rules;
Rule := Rules.Add;
Rule.Name(LocaleCodeID.Russian) := "Test rule";
Rule.Id := "RULE";
// Get rule index
Index := Rules.IndexOf(Rule);
// Display rule name and index in the console
Debug.WriteLine(Rule.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 rule
Index = 2
See also: