LogonHoursPolicy(Subject: ISecuritySubject): ILogonHoursPolicy;
Subject - the security subject for which it is necessary to distribute the access to the platform by time.
The LogonHoursPolicy property returns the access parameters to the platform by time for the security subject, passed via the Subject parameter.
Executing the example requires the user, registered in the platform with the User_1 identifier.
Sub Main;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
MP: IMetabasePolicy;
User: ISecuritySubject;
LogonHP: ILogonHoursPolicy;
LH: ILogonHours;
LHP: ILogonHoursPeriods;
d1, d2, d3, d4: DateTime;
Begin
MB := MetabaseClass.Active;
MS := MB.Security;
MP := MS.Policy;
User := MS.ResolveName("User_1");
LogonHP := MP.LogonHoursPolicy(User);
LHP := LogonHP.Periods;
LH := LHP.CreateHours;
d1 := DateTime.ComposeTimeOfDay(0, 0, 0, 0);
d2 := DateTime.ComposeTimeOfDay(9, 0, 0, 0);
d3 := DateTime.ComposeTimeOfDay(18, 0, 0, 0);
d4 := DateTime.ComposeTimeOfDay(23, 59, 0, 0);
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);
MS.Apply;
End Sub Main;
After executing this example the parameters of access in the determined time period for the User_1 user are changed. 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: