﻿

{"id":15644,"date":"2023-10-07T11:21:43","date_gmt":"2023-10-07T02:21:43","guid":{"rendered":"https:\/\/www.bitstrong.com\/jp\/?p=15644"},"modified":"2023-12-13T10:26:48","modified_gmt":"2023-12-13T01:26:48","slug":"person-based-access-control-configuring-authentication-mode-control-schedule","status":"publish","type":"post","link":"https:\/\/www.bitstrong.com\/jp\/person-based-access-control-configuring-authentication-mode-control-schedule\/","title":{"rendered":"\u3010Person-Based Access Control\u3011Configuring Authentication Mode Control Schedule"},"content":{"rendered":"<p><strong><span style=\"font-size: 18pt;\">\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0<\/span><\/strong><\/p>\n<div>\/\/<\/div>\n<div>\/\/ Device Network SDK (Person-Based Access Control)<\/div>\n<div>\/\/ Schedule Settings<\/div>\n<div>\/\/ Configure Authentication Mode Control Schedule<\/div>\n<div>\/\/ Sample Code for Configuring Authentication Mode Control Schedule<\/div>\n<div>\/\/<\/div>\n<div>#include &lt;stdio.h&gt;<\/div>\n<div>#include &lt;iostream&gt;<\/div>\n<div>#include &lt;afx.h&gt;<\/div>\n<div>#include &#8220;Windows.h&#8221;<\/div>\n<div>#include &#8220;HCNetSDK.h&#8221;<\/div>\n<p>using namespace std;<\/p>\n<div>void main()<\/div>\n<div>{<\/div>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Initialize<\/div>\n<p>NET_DVR_Init();<\/p>\n<div>\/\/Set connection timeout and reconnection function<\/div>\n<div>NET_DVR_SetConnectTime(2000, 1);<\/div>\n<p>NET_DVR_SetReconnect(10000, true);<\/p>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Log in to device<\/div>\n<div>LONG lUserID;<\/div>\n<div>\/\/Login parameters, including device IP address, user name, password, and so on<\/div>\n<div>NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};<\/div>\n<div>struLoginInfo.bUseAsynLogin = 0; \/\/Synchronous login mode<\/div>\n<div>strcpy(struLoginInfo.sDeviceAddress, &#8220;192.168.1.64&#8221;); \/\/Device IP address<\/div>\n<div>struLoginInfo.wPort = 8000; \/\/Device service port number<\/div>\n<div>strcpy(struLoginInfo.sUserName, &#8220;admin&#8221;); \/\/User name<\/div>\n<p>strcpy(struLoginInfo.sPassword, &#8220;abcd1234&#8221;); \/\/Password<\/p>\n<div>\/\/Device information, output parameter<\/div>\n<div>NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};<\/div>\n<p>lUserID = NET_DVR_Login_V40(&amp;struLoginInfo, &amp;struDeviceInfoV40);<\/p>\n<div>if (lUserID &lt; 0)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Login failed, error code: %d\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Set card reader authentication mode schedule, template 1 linked to card reader 1<\/div>\n<div>NET_DVR_CARD_READER_PLAN struCardReaderPlan = {0};<\/div>\n<div>struCardReaderPlan.dwSize = sizeof(struCardReaderPlan);<\/div>\n<div>struCardReaderPlan.dwTemplateNo = 1;\/\/Schedule template 1<\/div>\n<div>BOOL bRet1 = NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_CARD_READER_PLAN, 1, \\<\/div>\n<div>&amp;struCardReaderPlan, sizeof(struCardReaderPlan));<\/div>\n<div>if (!bRet1)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Setting card reader authentication mode schedule failed, error:%d.\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Set card reader authentication mode schedule template 1, template 1 links to week schedule 1 and holiday group 1<\/div>\n<div>CStringm_csTemplateName = &#8220;card reader authentication mode schedule template 1&#8221;;<\/div>\n<div>NET_DVR_PLAN_TEMPLATE struPlanTem = {0};<\/div>\n<div>struPlanTem.dwSize = sizeof(struPlanTem);<\/div>\n<div>struPlanTem.byEnable = 1;\/\/Enable or not: 0-No, 1-Yes<\/div>\n<div>strncpy((char *)struPlanTem.byTemplateName, (LPCTSTR)m_csTemplateName, TEMPLATE_NAME_LEN);<\/div>\n<div>struPlanTem.dwWeekPlanNo = 2;\/\/Week schedule No.2<\/div>\n<p>struPlanTem.dwHolidayGroupNo[0] = 2;\/\/Holiday group No.2, up to 16 holiday groups can be linked to each schedule<\/p>\n<div>BOOL bRet2 = NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_VERIFY_PLAN_TEMPLATE, 1, \\<\/div>\n<div>&amp;struPlanTem, sizeof(struPlanTem));<\/div>\n<div>if (!bRet2)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Setting card reader authentication mode schedule template failed, error:%d.\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Set week schedule 2 for card reader authentication mode<\/div>\n<div>NET_DVR_WEEK_PLAN_CFG struWeekPlan2 = {0};<\/div>\n<div>struWeekPlan2.dwSize = sizeof(struWeekPlan2);<\/div>\n<div>struWeekPlan2.byEnable = 1;\/\/Enable week schedule<\/div>\n<div>NET_DVR_SINGLE_PLAN_SEGMENT struSinglePlanSegment = {0};<\/div>\n<div>LPNET_DVR_SINGLE_PLAN_SEGMENT lpPlanSegment = &amp;struSinglePlanSegment;<\/div>\n<div>struSinglePlanSegment.byEnable = 1;<\/div>\n<div>struSinglePlanSegment.byVerifyMode = 4;\/\/Authentication mode: 0-invalid, 1-sleepy, 2-card+password, 3-card,<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/4-card or password, 5-fingerprint, 6-fingerprint+password, 7-fingerprint or card,<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/8-fingerprint+card, 9-fingerprint+card+password<\/div>\n<div>struSinglePlanSegment.struTimeSegment.struBeginTime.byHour = 0;\/\/Start time<\/div>\n<div>struSinglePlanSegment.struTimeSegment.struBeginTime.byMinute = 0;<\/div>\n<div>struSinglePlanSegment.struTimeSegment.struBeginTime.bySecond = 0;<\/div>\n<div>struSinglePlanSegment.struTimeSegment.struEndTime.byHour = 23;\/\/End time<\/div>\n<div>struSinglePlanSegment.struTimeSegment.struEndTime.byMinute = 59;<\/div>\n<p>struSinglePlanSegment.struTimeSegment.struEndTime.bySecond = 59;<\/p>\n<p>\/*Up to 8 time periods can be set for each day, and you can set different authentication modes for each time period Here only takes setting one period for each day*\/<\/p>\n<div>for (int iDate = 0; iDate&lt;MAX_DAYS; iDate++)<\/div>\n<div>{<\/div>\n<div>memcpy(&amp;struWeekPlan2.struPlanCfg[iDate][0], lpPlanSegment, sizeof(struSinglePlanSegment));<\/div>\n<p>}<\/p>\n<div>BOOL bRet3 = NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_VERIFY_WEEK_PLAN, 2, \\<\/div>\n<div>&amp;struWeekPlan2, sizeof(struWeekPlan2));<\/div>\n<div>if (!bRet3)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Setting week schedule for card reader authentication mode failed,error:%d.\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Set holiday group for card reader authentication mode<\/div>\n<div>CStringm_csGroupName = &#8220;Holiday group 2&#8221;;<\/div>\n<div>NET_DVR_HOLIDAY_GROUP_CFG struHolidayGroup2 = {0};<\/div>\n<div>struHolidayGroup2.dwSize = sizeof(struHolidayGroup2);<\/div>\n<div>struHolidayGroup2.byEnable = 1;<\/div>\n<div>strncpy((char *)struHolidayGroup2.byGroupName, (LPCTSTR)m_csGroupName, HOLIDAY_GROUP_NAME_LEN);<\/div>\n<div>struHolidayGroup2.dwHolidayPlanNo[0] = 2;\/\/Holiday group 1 links to holiday schedule 1,<\/div>\n<p>\/\/up to 16 holiday schedules can be linked to one holiday group<\/p>\n<div>BOOL bRet4 = NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_VERIFY_HOLIDAY_GROUP, 2, \\<\/div>\n<div>&amp;struHolidayGroup2, sizeof(struHolidayGroup2));<\/div>\n<div>if (!bRet4)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;\u8bbeSetting holiday group for card reader authentication mode failed, error:%d.\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Set holiday schedule for card reader authentication mode<\/div>\n<div>NET_DVR_HOLIDAY_PLAN_CFG struHolidayPlan2 = {0};<\/div>\n<div>struHolidayPlan2.dwSize = sizeof(struHolidayPlan2);<\/div>\n<div>struHolidayPlan2.byEnable = 1;<\/div>\n<div>struHolidayPlan2.struBeginDate.wYear = 2017;\/\/Holiday start date<\/div>\n<div>struHolidayPlan2.struBeginDate.byMonth = 10;<\/div>\n<div>struHolidayPlan2.struBeginDate.byDay = 1;<\/div>\n<div>struHolidayPlan2.struEndDate.wYear = 2017;\/\/Holiday end date<\/div>\n<div>struHolidayPlan2.struEndDate.byMonth = 10;<\/div>\n<div>struHolidayPlan2.struEndDate.byDay = 7;<\/div>\n<div>\/\/Copy the week schedule parameters to holiday schedule of card reader authentication mode<\/div>\n<p>memcpy(struHolidayPlan2.struPlanCfg, struWeekPlan2.struPlanCfg, sizeof(NET_DVR_SINGLE_PLAN_SEGMENT)*MAX_DAYS*MAX_TIMESEGMENT_V30);<\/p>\n<div>BOOL bRet5 = NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_VERIFY_HOLIDAY_PLAN, 2, \\<\/div>\n<div>&amp;struHolidayPlan2, sizeof(struHolidayPlan2));<\/div>\n<div>if (!bRet5)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Setting holiday schedule for card reader authentication mode failed, error:%d.\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Exit<\/div>\n<p>Sleep(5000);<\/p>\n<div>\/\/Log out<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>\/\/Release SDK resource<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<div>}<\/div>\n","protected":false},"excerpt":{"rendered":"\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0 \/\/ \/\/ Device Network SDK (Person-Based Access Control) \/\/ Schedule Settings \/\/ Configure Authentication Mode Control Schedule \/\/ Sample Code for...","protected":false},"author":2,"featured_media":15936,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[107],"tags":[],"class_list":["post-15644","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-camera-connection"],"_links":{"self":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/comments?post=15644"}],"version-history":[{"count":5,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15644\/revisions"}],"predecessor-version":[{"id":15731,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15644\/revisions\/15731"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media\/15936"}],"wp:attachment":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media?parent=15644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/categories?post=15644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/tags?post=15644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}