Attributes: IABACAttributes;
Attributes: Prognoz.Platform.Interop.ABAC.IABACAttributes;
The Attributes property returns attributes collection.
The property is read-only.
To work with the attributes collection, use the IABACAttributes interface.
To execute the example, place the Button component named Button1 and two Memo components named Memo1/listBox1 and Memo2/listBox2 (use two ListBox components for the Fore.NET example) on the form. Set the ScrollBars property to Vertical for Memo1.
Add links to the system assemblies:
For the Fore example: ABAC, Metabase, Collections, Dal, Forms.
For the Fore.NET example: ABAC, Metabase, Dal, Forms.NET.
The example is a handler of the OnClick event for the Button1 component.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
MS: IMetabasePolicy;
AttrObj: IMetabaseSecurityObjectsAttributes;
ABACAttributes: IABACAttributes;
ABACAttribute: IABACAttribute;
Begin
MB := MetabaseClass.Active;
MS := MB.Security.Policy;
// Get object attributes
AttrObj := MS.ObjectsAttributes;
ABACAttributes := AttrObj.Global;
// Display properties of each attribute
For Each ABACAttribute In ABACAttributes Do
Memo1.Lines.Add("Key: " + ABACAttribute.Key.ToString);
Memo1.Lines.Add("ID: " + ABACAttribute.Id);
Memo1.Lines.Add("Name: " + ABACAttribute.Name(MB.CurrentLocale));
Memo1.Lines.Add("Description: " + ABACAttribute.Description(MB.CurrentLocale));
Memo1.Lines.Add("Data type: " + ABACAttribute.DataType.ToString);
Memo1.Lines.Add("Default value: " + ABACAttribute.DefaultValue);
Memo1.Lines.Add("=========================================");
Memo2.Lines.Add("Total in collection: " + ABACAttribute.Attributes.Count.ToString + " attributes");
End For;
End Sub Button1OnClick;
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.ABAC;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dal;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
MS: IMetabasePolicy;
AttrObj: IMetabaseSecurityObjectsAttributes;
ABACAttributes: IABACAttributes;
ABACAttribute: IABACAttribute;
Begin
MB := Self.Metabase;
MS := MB.Security.Policy;
// Get object attributes
AttrObj := MS.ObjectsAttributes;
ABACAttributes := AttrObj.Global;
// Display properties of each attribute
For Each ABACAttribute In ABACAttributes Do
listBox1.Items.Add("Key: " + ABACAttribute.Key.ToString());
listBox1.Items.Add("ID: " + ABACAttribute.Id);
listBox1.Items.Add("Name: " + ABACAttribute.Name[MB.CurrentLocale]);
listBox1.Items.Add("Description: " + ABACAttribute.Description[MB.CurrentLocale]);
listBox1.Items.Add("Data type: " + ABACAttribute.DataType.ToString());
listBox1.Items.Add("Default value: " + ABACAttribute.DefaultValue);
listBox1.Items.Add("=========================================");
listBox2.Items.Add("Total in collection: " + ABACAttribute.Attributes.Count.ToString() + " attributes");
End For;
End Sub;
After clicking the button the properties of system and custom object attributes are displayed:
See also: