Opens a standard dialog box that is used to select security subjects.
Command parameters are passed in the Data property. Executing the command requires to specify an array of the Variant type in this property, the elements of this array contain the following values:
Value type | Description |
Element 1: IMetabaseSecurity | The repository security manager, using which the list of security subjects will be created. |
Element 2: SecuritySubjectType | The type of security subjects available to be selected in the dialog box. |
Element 3: SecuritySubjectLocation | The layout of available security subjects that will be available to select. |
After executing the Execute method and clicking the OK button the method returns an array if the dialog box contains a correct list of security subjects. Each array element contains a selected security subject.
Executing the example requires a form and a button named Button1 on the form. The repository contains a table dictionary with the Dim_1 identifier. By default, dictionary security labels are associated with two subjects (the Admin user and the Administrators group). At least 32 security subjects can be selected in the dialog box.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
Sec: IMetabaseSecurity;
Target: IUiCommandTarget;
Context: IUiCommandExecutionContext;
Params: Array[0..2];
SubType: SecuritySubjectType;
SubLoc: SecuritySubjectLocation;
SS: ISecuritySubject;
Res: Variant;
v: Array;
i, j: Integer;
MDesc: IMetabaseObjectDescriptor;
SecDesc: ISecurityDescriptor;
SecLab: ISecurityLabels;
Begin
MB := MetabaseClass.Active;
Target := WinApplication.Instance.GetPluginTarget("Std");
Context := Target.CreateExecutionContext;
Sec := MB.Security;
SubType := SecuritySubjectType.User;
SubLoc := SecuritySubjectLocation.DbUsers;
//Define parameters for the dialog box
Params[0] := Sec;
Params[1] := SubType;
Params[2] := SubLoc;
Context.Data := Params;
//Dialog initialization
Res := Target.Execute("SelectSecSubject", Context);
//If OK - Match with unoccupied security labels
If Not Res.IsNull Then
MDesc := MB.ItemById("Dim_1");
SecDesc := MDesc.SecurityDescriptor;
SecDesc.Edit;
SecLab := SecDesc.LabelSecurity;
v := Res As Array;
For i := 0 To SecLab.BitCount - 1 Do
If SecLab.Mapping(i) = Null Then
SS := v[j] As ISecuritySubject;
SecLab.Mapping(i) := SS;
j := j + 1;
End If;
If j >= v.Length Then
Break;
End If;
End For;
SecDesc.Apply(False);
End If;
End Sub Button1OnClick;
After executing the example clicking the button initializes a dialog box where security subjects selection dialog box will open. In the dialog box the user can select users created within the current repository. After the users are selected and the OK button is clicked, these security subjects are to be associated with unoccupied dictionary security labels.
See also: