IAccessObjectSecurity.GetElements

Syntax

GetElements: IAccessElementsIterator;

Description

The GetElements method gets the set of access elements in the hierarchical form.

Example

Executing the example requires the Button component named Button1 and the TreeList component named TreeList1 on the form. 5 columns have to be created for the TreeList component: Name, ReadAccess, WriteAccess, DeleteAccess, AccessAccess. An MDM repository with the MDM identifier and an MDM dictionary with the Dict_1 identifier should be in the scheme.

Class UserForm: Form

Button1: Button;

TreeList1: TreeList;

 

Sub FillViewer(Iterator : IAccessElementsIterator; currentlevel:integer; parentNode : ITreeListNode);

Var

level : integer;

node : ITreeListNode;

element : IAccessElement;

Begin

level := iterator.Next;

If level<>-1 Then

element := iterator.Current;

node := TreeList1.Nodes.AddChild(GetParent(parentNode,currentlevel,level),element.Name);

node.Data := element;

node.ColumnText(1) := element.AttributeAccess(AccessElementAttributes.Read).ToString;

node.ColumnText(2) := element.AttributeAccess(AccessElementAttributes.Write).ToString;

node.ColumnText(3) := element.AttributeAccess(AccessElementAttributes.Delete).ToString;

node.ColumnText(4) := element.AttributeAccess(AccessElementAttributes.Access).ToString;

FillViewer(iterator,level,node);

End If;

End Sub FillViewer;

 

Function GetParent(node : ITreeListNode; currentLevel : integer; level : integer):ITreeListNode;

Begin

If (level-currentLevel)=1 Then

Return node;

End If;

If currentLevel>= level Then

currentLevel := currentLevel-1;

Else

level := level-1;

End If;

Return GetParent(node.Parent,currentLevel,level);

End Function GetParent;

 

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

MB : IMetabase;

Object : IMetabaseObjectDescriptor;

SD : ISecurityDescriptor;

AOS : IAccessObjectSecurity;

Iterator : IAccessElementsIterator;

Begin

MB := MetabaseClass.Active;

Object := MB.ItemByIdNamespace("Dict_1", MB.ItemById("RDS").Key);

AOS := Object.GetSecurity;

Iterator := AOS.GetElements;

FillViewer(Iterator,-1,Null);

End Sub Button1OnClick;

 

End Class UserForm;

Clicking the button displays a tree of MDM dictionary elements in the TreeList component and the values, stored in access attributes, are displayed in respective columns for each element.

See also:

IAccessObjectSecurity