IMetabaseUpdateMandatoryAccess.Category

Fore Syntax

Category: IMetabaseUpdateSecurityCategory;

Fore.NET Syntax

Category: Prognoz.Platform.Interop.Metabase.IMetabaseUpdateSecurityCategory;

Description

The Category property returns the category by index.

Fore Example

To execute the example add links to the Metabase and Stat system assemblies. The D:\Update.pefx update file is required.

Sub main;
Var
    Mb: IMetabase;
    Upd: IMetabaseUpdate;
Begin   
    MB := MetabaseClass.Active;
    Upd := Mb.CreateUpdate;
    Upd.LoadFromFileNF("D:\Update.pefx");
    Upd.Prepare;
    updateMandatory(Upd);
    Upd.SaveAvailable("D:\Update.pefx");
End Sub main;

Sub updateMandatory (update: IMetabaseUpdate);
    Var
        muma: IMetabaseUpdateMandatoryAccess;
        musc: IMetabaseUpdateSecurityCategory;
        musl: IMetabaseUpdateSecurityLevel;
        i, j: integer;
        mma: IMetabaseMandatoryAccess;
        Mb: IMetabase;      
    Begin
        Mb := MetabaseClass.Active;     
        muma := update.MandatoryAccess;
        mma := Mb.Security.Policy.MandatoryAccess;
        debug.WriteLine("Whether the mandatory control is enabled in the base of the consumer:  "+Mb.Security.Policy.MandatoryAccessControl.ToString);
        For i := 0 To muma.CategoryCount - 1 Do
            musc := muma.Category(i);
            If musc.Exists.ToString <> "True" Then
                debug.WriteLine("New category is required:  "+musc.Name);
            Else
            debug.WriteLine("Name of the category in the base of the consumer:  "+musc.Name);
            debug.WriteLine("Key of the category in the base of the consumer:  "+musc.Key.ToString);
            debug.WriteLine("Availability of the category in the base of the consumer:  "+musc.IsValid.ToString);
            For j := 0 To musc.LevelCount - 1 Do
                musl := musc.Level(j);
                If musl.Exists.ToString <> "True" Then
                    debug.WriteLine("New level of the category is required:  "+musl.Name+" ("+musl.Category.Name+")");
                Else
                debug.WriteLine("Name of the security level (category) in the base of the consumer:  "+musc.FindLevelByLabel(musl.Index).Name+" ("+musl.Category.Name+")");
                debug.WriteLine("Existence of the security level in the base of the consumer:  "+musc.Level(j).Exists.ToString+ " Label of the security level:  "+musl.CriticalityLabel.ToString);
                debug.WriteLine("Description of the security level in the base of the consumer:  "+musl.Description);
                debug.WriteLine("Availability of the security level in the base of the consumer:  "+musl.IsValid.ToString);
                End If;
            End For;
            End If;
        End For;
End Sub updateMandatory;

After executing the example the console window displays the information about using the mandatory control in the base, on which the module is launched, about the existence of the appropriate categories and levels from the update in the base, on which the module is launched and the information about the corresponding categories and levels.

Fore.NET Example

To execute the example, add links to the Metabase and Stat system assemblies. The D:\Update.pefx update file is required.

Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Upd: IMetabaseUpdate;
Begin   
    MB := Params.Metabase;
    Upd := MB.CreateUpdate();
    Upd.LoadFromFileNF("D:\""Update.pefx",UpdateLoadMode.ulmReplace);
    Upd.Prepare();
    updateMandatory(MB, Upd);
    Upd.SaveAvailable("D:\""Update.pefx",MetabaseUpdateCopyType.muctAvailable);
End Sub main;

Shared Sub updateMandatory (MB: IMetabase; update: IMetabaseUpdate);
    Var
        muma: IMetabaseUpdateMandatoryAccess;
        musc: IMetabaseUpdateSecurityCategory;
        musl: IMetabaseUpdateSecurityLevel;
        i, j: integer;
        mma: IMetabaseMandatoryAccess;
    Begin
        muma := update.MandatoryAccess;
        mma := MB.Security.Policy.MandatoryAccess;
        System.Diagnostics.Debug.WriteLine("Whether the mandatory control is disabled in the base of the consumer:  "+MB.Security.Policy.MandatoryAccessControl.ToString());
        For i := 0 To muma.CategoryCount - 1 Do
            musc := muma.Category[i];
            If musc.Exists.ToString() <> "True" Then
                System.Diagnostics.Debug.WriteLine("New category is required:  "+musc.Name);
            Else
            System.Diagnostics.Debug.WriteLine("Name of the category in the base of the consumer:  "+musc.Name);
            System.Diagnostics.Debug.WriteLine("Key of the category in the base of the consumer:  "+musc.Key.ToString());
            System.Diagnostics.Debug.WriteLine("Availability of the category in the base of the consumer:  "+musc.IsValid.ToString());
            For j := 0 To musc.LevelCount - 1 Do
                musl := musc.Level[j];
                If musl.Exists.ToString() <> "True" Then
                    System.Diagnostics.Debug.WriteLine("New level of the category is required:  "+musl.Name+" ("+musl.Category.Name+")");   
                Else
                System.Diagnostics.Debug.WriteLine("Name of the security level (category) in the base of the consumer:  "+musc.FindLevelByLabel(musl.Index As uinteger).Name+" ("+musl.Category.Name+")");
                System.Diagnostics.Debug.WriteLine("Existence of the security level in the base of the consumer:  "+musc.Level[j].Exists.ToString()+ " Label of the security level:  "+musl.CriticalityLabel.ToString());
                System.Diagnostics.Debug.WriteLine("Description of the security level in the base of the consumer:  "+musl.Description);
                System.Diagnostics.Debug.WriteLine("Availability of the security level in the base of the consumer:  "+musl.IsValid.ToString());
                End If;
            End For;
            End If;
        End For;
End Sub updateMandatory;

After executing the example the console window displays the information about using the mandatory control in the base, on which the module is launched, about the existence of the appropriate categories and levels from the update in the base, on which the module is launched and the information about the corresponding categories and levels.

See also:

IMetabaseUpdateMandatoryAccess