ILogonHoursPeriods.CreateHours

Syntax

CreateHours: ILogonHours;

Description

The CreateHours method creates an object used to set up access by hours during the day.

Example

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

Add a link to the Metabase system assembly.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    MP: IMetabasePolicy;
    User: ISecuritySubject;
    LogonHP: ILogonHoursPolicy;
    LH: ILogonHours;
    LHP: ILogonHoursPeriods;
    d1, d2, d3, d4: DateTime;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    MP := MS.Policy;
    
// Get user parameters
    User := MS.ResolveName("USER");
    LogonHP := MP.LogonHoursPolicy(User);
    LHP := LogonHP.Periods;
    
// Add a period to enable access
    LH := LHP.CreateHours;
    d1 := DateTime.ComposeTimeOfDay(
0000);
    d2 := DateTime.ComposeTimeOfDay(
9000);
    d3 := DateTime.ComposeTimeOfDay(
18000);
    d4 := DateTime.ComposeTimeOfDay(
235900);
    LH.SetPeriodAccess(d1, d2, 
False);
    LH.SetPeriodAccess(d2, d3, 
True);
    LH.SetPeriodAccess(d3, d4, 
False);
    d1 := DateTime.Now;
    d2 := DateTime.AddDays(d1, 
30);
    LHP.SetPeriodAccess(d1, d2, LH);
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub UserProc;

After executing the example access parameters are changed in a certain period of time for the USER user. Since this day and during the next 30 days access under this user has been possible from 9 a.m. to 6 p.m.

See also:

ILogonHoursPeriods