ISecuritySubject.LogonHoursPolicy

Syntax

LogonHoursPolicy: ILogonHoursPolicy;

LogonHoursPolicy: Prognoz.Platform.Interop.Metabase.ILogonHoursPolicy;

Description

The LogonHoursPolicy property returns settings of the security subject access to the Prognoz Platform by times.

Example

To execute the example, make sure that security manager contains the USER user.

Add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    MP: IMetabasePolicy;
    User: ISecuritySubject;
    LogonHP: ILogonHoursPolicy;
    LH: ILogonHours;
    d1, d2, d3, d4: DateTime;
    i: Integer;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    MP := MS.Policy;
    
// Get user parameters
    User := MS.ResolveName("USER");
    
// Add schedule to enable access
    LogonHP := User.LogonHoursPolicy;
    d1 := DateTime.ComposeTimeOfDay(
0000);
    d2 := DateTime.ComposeTimeOfDay(
9000);
    d3 := DateTime.ComposeTimeOfDay(
18000);
    d4 := DateTime.ComposeTimeOfDay(
235900);
    
For i := 1 To 5 Do
        LH := LogonHP.WeekDayHours(i 
As CalendarDayOfWeek);
        LH.SetPeriodAccess(d1, d2, 
False);
        LH.SetPeriodAccess(d2, d3, 
True);
        LH.SetPeriodAccess(d3, d4, 
False);
        LogonHP.WeekDayHours(i 
As CalendarDayOfWeek) := LH;
    
End For;
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    MP: IMetabasePolicy;
    User: ISecuritySubject;
    LogonHP: ILogonHoursPolicy;
    LH: ILogonHours;
    d1, d2, d3, d4: DateTime;
    i: Integer;
    Lic: Object;
Begin
    MB := Params.Metabase;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    MS := MB.Security;
    MP := MS.Policy;
    
// Get user parameters
    User := MS.ResolveName("USER");
    
// Add schedule to enable access
    LogonHP := User.LogonHoursPolicy;
    d1 := DateTime.Parse(
"0:00:00");
    d2 := DateTime.Parse(
"9:00:00");
    d3 := DateTime.Parse(
"18:00:00");
    d4 := DateTime.Parse(
"23:59:59");
    
For i := 1 To 5 Do
        LH := LogonHP.WeekDayHours[i 
As CalendarDayOfWeek];
        LH.SetPeriodAccess(d1, d2, 
False);
        LH.SetPeriodAccess(d2, d3, 
True);
        LH.SetPeriodAccess(d3, d4, 
False);
        LogonHP.WeekDayHours[i 
As CalendarDayOfWeek] := LH;
    
End For;
    
// Save changes
    MS.Apply();
    
// Check in license
    Lic := Null;
End Sub;

After executing the example, access parameters by days of week for the USER user are changed. Access under this user is available from Monday to Friday, from 9 AM till 6 PM.

See also:

ISecuritySubject