Compare commits
No commits in common. "master" and "2.0" have entirely different histories.
8 changed files with 186 additions and 99 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
|
@ -1,13 +0,0 @@
|
||||||
# /
|
|
||||||
/ARM64
|
|
||||||
/Win32
|
|
||||||
/x64
|
|
||||||
|
|
||||||
# /LockIfOutOfLogonHours/
|
|
||||||
/LockIfOutOfLogonHours/*.user
|
|
||||||
/LockIfOutOfLogonHours/Debug.ARM64
|
|
||||||
/LockIfOutOfLogonHours/Debug.Win32
|
|
||||||
/LockIfOutOfLogonHours/Debug.x64
|
|
||||||
/LockIfOutOfLogonHours/Release.ARM64
|
|
||||||
/LockIfOutOfLogonHours/Release.Win32
|
|
||||||
/LockIfOutOfLogonHours/Release.x64
|
|
||||||
19
COPYING
19
COPYING
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright © 2015-2020 Simon Rozman (simon@rozman.si)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and associated documentation files (the "Software"),
|
|
||||||
to deal in the Software without restriction, including without limitation
|
|
||||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
// SPDX-License-Identifier: MIT
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright © 2015-2020 Simon Rozman (simon@rozman.si)
|
//
|
||||||
|
// LockIfOutOfLogonHours - Locks current session if user is out of logon hours
|
||||||
|
//
|
||||||
|
// Copyright © 2015 Simon Rozman (simon@rozman.si)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define SECURITY_WIN32
|
#define SECURITY_WIN32
|
||||||
|
|
||||||
|
|
@ -8,10 +13,10 @@
|
||||||
#include <Security.h>
|
#include <Security.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
static void GetLogonHoursIndices(_In_ const SYSTEMTIME* time, _In_ const TIME_ZONE_INFORMATION* tzi, _Out_ LONG* plIndexSA, _Out_ LONG* plIndexBit)
|
static void GetLogonHoursIndices(_In_ const SYSTEMTIME *time, _In_ const TIME_ZONE_INFORMATION *tzi, _Out_ LONG *plIndexSA, _Out_ LONG *plIndexBit)
|
||||||
{
|
{
|
||||||
LONG wIndex = (((LONG)time->wDayOfWeek * 24 + time->wHour) * 60 + time->wMinute + tzi->Bias) / 60 % (21 * 8);
|
LONG wIndex = (((LONG)time->wDayOfWeek * 24 + time->wHour) * 60 + time->wMinute + tzi->Bias) / 60 % (21*8);
|
||||||
*plIndexSA = wIndex / 8;
|
*plIndexSA = wIndex / 8,
|
||||||
*plIndexBit = wIndex % 8;
|
*plIndexBit = wIndex % 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,8 +35,7 @@ static LPTSTR FormatMsg(_In_z_ LPCTSTR lpFormat, ...)
|
||||||
&arg)) {
|
&arg)) {
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
return lpBuffer;
|
return lpBuffer;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +54,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
UINT uiResult;
|
UINT uiResult;
|
||||||
HANDLE hHeap = GetProcessHeap();
|
HANDLE hHeap = GetProcessHeap();
|
||||||
LPTSTR pszADsPath;
|
LPTSTR pszADsPath;
|
||||||
IDispatch* pUserObj;
|
IDispatch *pUserObj;
|
||||||
DISPID dispidUserObjectMembers[_countof(ppszUserObjectMembers)];
|
DISPID dispidUserObjectMembers[_countof(ppszUserObjectMembers)];
|
||||||
VARIANT varLogonHours = { VT_EMPTY };
|
VARIANT varLogonHours = { VT_EMPTY };
|
||||||
|
|
||||||
|
|
@ -61,7 +65,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
|
|
||||||
// Get user fully qualified DN.
|
// Get user fully qualified DN.
|
||||||
for (ULONG nLength = 1024; ;) {
|
for (ULONG nLength = 1024; ;) {
|
||||||
if ((pszADsPath = (LPTSTR)HeapAlloc(hHeap, 0, (nLength + _countof(pszURIPrefix) - 1) * sizeof(TCHAR))) == NULL) {
|
if ((pszADsPath = (LPTSTR)HeapAlloc(hHeap, 0, (nLength + _countof(pszURIPrefix) - 1)*sizeof(TCHAR))) == NULL) {
|
||||||
uiResult = 3; // Out of memory
|
uiResult = 3; // Out of memory
|
||||||
goto _cleanup2;
|
goto _cleanup2;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +81,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add LDAP URI prefix.
|
// Add LDAP URI prefix.
|
||||||
CopyMemory(pszADsPath, pszURIPrefix, (_countof(pszURIPrefix) - 1) * sizeof(TCHAR));
|
CopyMemory(pszADsPath, pszURIPrefix, (_countof(pszURIPrefix) - 1)*sizeof(TCHAR));
|
||||||
|
|
||||||
if (FAILED(CoGetObject(pszADsPath, NULL, IID_IDispatch, (void**)&pUserObj))) {
|
if (FAILED(CoGetObject(pszADsPath, NULL, IID_IDispatch, (void**)&pUserObj))) {
|
||||||
uiResult = 5; // Get user object failed
|
uiResult = 5; // Get user object failed
|
||||||
|
|
@ -97,8 +101,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
if (V_VT(&varLogonHours) == VT_EMPTY) {
|
if (V_VT(&varLogonHours) == VT_EMPTY) {
|
||||||
uiResult = 0; // User has no logon hours defined
|
uiResult = 0; // User has no logon hours defined
|
||||||
goto _cleanup5;
|
goto _cleanup5;
|
||||||
}
|
} else if (V_VT(&varLogonHours) != (VT_ARRAY | VT_UI1)) {
|
||||||
else if (V_VT(&varLogonHours) != (VT_ARRAY | VT_UI1)) {
|
|
||||||
uiResult = 7; // Invalid logon hours
|
uiResult = 7; // Invalid logon hours
|
||||||
goto _cleanup5;
|
goto _cleanup5;
|
||||||
}
|
}
|
||||||
|
|
@ -119,34 +122,24 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
}
|
}
|
||||||
if (bData & (1 << lIndexBit)) {
|
if (bData & (1 << lIndexBit)) {
|
||||||
uiResult = 0; // Within logon hours
|
uiResult = 0; // Within logon hours
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
uiResult = 1; // Out of logon hours
|
uiResult = 1; // Out of logon hours
|
||||||
LockWorkStation();
|
LockWorkStation();
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEMTIME timeFuture = time;
|
time.wMinute += 10;
|
||||||
timeFuture.wMinute += 10;
|
GetLogonHoursIndices(&time, &time_zone, &lIndexSA, &lIndexBit);
|
||||||
GetLogonHoursIndices(&timeFuture, &time_zone, &lIndexSA, &lIndexBit);
|
|
||||||
if (FAILED(SafeArrayGetElement(V_ARRAY(&varLogonHours), &lIndexSA, &bData))) {
|
if (FAILED(SafeArrayGetElement(V_ARRAY(&varLogonHours), &lIndexSA, &bData))) {
|
||||||
uiResult = 8; // Logon hour index not found
|
uiResult = 8; // Logon hour index not found
|
||||||
goto _cleanup5;
|
goto _cleanup5;
|
||||||
}
|
}
|
||||||
if (uiResult == 0 && !(bData & (1 << lIndexBit))) {
|
if (uiResult == 0 && !(bData & (1 << lIndexBit))) {
|
||||||
// Within logon hours now, but out of logon hours in up to 10 minutes.
|
// Within logon hours now, but out of logon hours in 10 min.
|
||||||
HINSTANCE hShell32Res = LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
HINSTANCE hShell32Res = LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
||||||
LPTSTR lpTitleFmt;
|
LPTSTR lpTitle, lpMsgFmt, lpMsg;
|
||||||
LoadString(hInstance, IDS_WARNING_TITLE_FMT, (LPTSTR)&lpTitleFmt, 0);
|
LoadString(hInstance, IDS_WARNING_TITLE, (LPTSTR)&lpTitle, 0);
|
||||||
TCHAR szDate[0x100];
|
|
||||||
GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &time, NULL, szDate, _countof(szDate));
|
|
||||||
szDate[_countof(szDate) - 1] = 0;
|
|
||||||
TCHAR szTime[0x100];
|
|
||||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time, NULL, szTime, _countof(szTime));
|
|
||||||
szTime[_countof(szTime) - 1] = 0;
|
|
||||||
LPTSTR lpTitle = FormatMsg(lpTitleFmt, szDate, szTime);
|
|
||||||
LPTSTR lpMsgFmt;
|
|
||||||
LoadString(hInstance, IDS_WARNING_MSG_FMT, (LPTSTR)&lpMsgFmt, 0);
|
LoadString(hInstance, IDS_WARNING_MSG_FMT, (LPTSTR)&lpMsgFmt, 0);
|
||||||
LPTSTR lpMsg = FormatMsg(lpMsgFmt, 60 - time.wMinute);
|
lpMsg = FormatMsg(lpMsgFmt, 70 - time.wMinute);
|
||||||
MSGBOXPARAMS params = {
|
MSGBOXPARAMS params = {
|
||||||
sizeof(MSGBOXPARAMS), // cbSize
|
sizeof(MSGBOXPARAMS), // cbSize
|
||||||
NULL, // hwndOwner
|
NULL, // hwndOwner
|
||||||
|
|
@ -158,7 +151,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
};
|
};
|
||||||
MessageBoxIndirect(¶ms);
|
MessageBoxIndirect(¶ms);
|
||||||
LocalFree(lpMsg);
|
LocalFree(lpMsg);
|
||||||
LocalFree(lpTitle);
|
|
||||||
FreeLibrary(hShell32Res);
|
FreeLibrary(hShell32Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
// SPDX-License-Identifier: MIT
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright © 2015-2020 Simon Rozman (simon@rozman.si)
|
//
|
||||||
|
// LockIfOutOfLogonHours - Locks current session if user is out of logon hours
|
||||||
|
//
|
||||||
|
// Copyright © 2015 Simon Rozman (simon@rozman.si)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
#ifndef __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||||
#define __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
#define __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||||
|
|
||||||
#define IDS_WARNING_TITLE_FMT 0
|
#define IDS_WARNING_TITLE 0
|
||||||
#define IDS_WARNING_MSG_FMT 1
|
#define IDS_WARNING_MSG_FMT 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -35,41 +35,102 @@
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)$(Platform)\</OutDir>
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup>
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||||
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||||
|
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<ResourceCompile>
|
<ResourceCompile>
|
||||||
|
|
@ -79,24 +140,108 @@
|
||||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
</Manifest>
|
</Manifest>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<ResourceCompile>
|
||||||
|
<NullTerminateStrings>true</NullTerminateStrings>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Manifest>
|
||||||
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
|
</Manifest>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<ResourceCompile>
|
||||||
|
<NullTerminateStrings>true</NullTerminateStrings>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Manifest>
|
||||||
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
|
</Manifest>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<ResourceCompile>
|
||||||
|
<NullTerminateStrings>true</NullTerminateStrings>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Manifest>
|
||||||
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
|
</Manifest>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<ResourceCompile>
|
||||||
|
<NullTerminateStrings>true</NullTerminateStrings>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Manifest>
|
||||||
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
|
</Manifest>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<ResourceCompile>
|
||||||
|
<NullTerminateStrings>true</NullTerminateStrings>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Manifest>
|
||||||
|
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||||
|
</Manifest>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="LockIfOutOfLogonHours.cpp" />
|
<ClCompile Include="LockIfOutOfLogonHours.cpp" />
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -1,23 +0,0 @@
|
||||||
# LockIfOutOfLogonHours - Lock Windows User Desktop When Logon Hours Denied
|
|
||||||
|
|
||||||
LockIfOutOfLogonHours is a small utility to test if the invoking user is within permitted logon hours or not.
|
|
||||||
|
|
||||||
If not, the utility locks the user desktop, locking the user out but not killing users' work.
|
|
||||||
|
|
||||||
If logon hours are to expire within 10 minutes, a prompt is displayed encouraging the user to finish her/his work in time.
|
|
||||||
|
|
||||||
## Running
|
|
||||||
|
|
||||||
Use Task Scheduler to schedule the `LockIfOutOfLogonHours.exe` to run periodically as the interactive user.
|
|
||||||
|
|
||||||
Active Directory allows configuring logon hours rounded to the whole hours only. Therefore, it makes sense to trigger the `LockIfOutOfLogonHours.exe` to run:
|
|
||||||
|
|
||||||
- Sometime before the hour is out (up to 10 minutes before the hour is out, e.g. 0:55, 1:55, ..., 23:55). This trigger notifies the user.
|
|
||||||
|
|
||||||
- At or just after the hour is out (e.g. 0:01, 1:01, ..., 23:01). This trigger locks the user out.
|
|
||||||
|
|
||||||
A sample task XML to be imported in Task Scheduler can be found in [`samples\LockIfOutOfLogonHours.xml`](samples/LockIfOutOfLogonHours.xml).
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
Microsoft Visual Studio 2019 is required.
|
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue