SetPeriodAccess(Begin_: DateTime; End_: DateTime; Value: ILogonHours);
Begin_ - an initial date of the period in which the time of access should be restricted.
Begin_ - a final date of the period in which the time of access should be restricted.
Value - settings of access by hours during the day.
The SetPeriodAccess method sets parameters of the user access for the specified period.
Period is formed setting initial and final date in the Begin_ and End_ parameters, respectively. Parameters of access during the day within the whole period are passed in the Value 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: