Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
b5df8230f0 | |||
7c31b0bca6 | |||
912814c70a | |||
60d4da100e | |||
908fec06e4 | |||
6023e8be89 | |||
33ac1031d9 | |||
ebdcc0ecab | |||
eb4b3fae4c | |||
967aa86b33 |
8 changed files with 113 additions and 200 deletions
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# /
|
||||
/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
Normal file
19
COPYING
Normal file
|
@ -0,0 +1,19 @@
|
|||
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,10 +1,5 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LockIfOutOfLogonHours - Locks current session if user is out of logon hours
|
||||
//
|
||||
// Copyright © 2015 Simon Rozman (simon@rozman.si)
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright © 2015-2020 Simon Rozman (simon@rozman.si)
|
||||
|
||||
#define SECURITY_WIN32
|
||||
|
||||
|
@ -13,10 +8,10 @@
|
|||
#include <Security.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);
|
||||
*plIndexSA = wIndex / 8,
|
||||
LONG wIndex = (((LONG)time->wDayOfWeek * 24 + time->wHour) * 60 + time->wMinute + tzi->Bias) / 60 % (21 * 8);
|
||||
*plIndexSA = wIndex / 8;
|
||||
*plIndexBit = wIndex % 8;
|
||||
}
|
||||
|
||||
|
@ -35,7 +30,8 @@ static LPTSTR FormatMsg(_In_z_ LPCTSTR lpFormat, ...)
|
|||
&arg)) {
|
||||
va_end(arg);
|
||||
return lpBuffer;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
va_end(arg);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -54,7 +50,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
UINT uiResult;
|
||||
HANDLE hHeap = GetProcessHeap();
|
||||
LPTSTR pszADsPath;
|
||||
IDispatch *pUserObj;
|
||||
IDispatch* pUserObj;
|
||||
DISPID dispidUserObjectMembers[_countof(ppszUserObjectMembers)];
|
||||
VARIANT varLogonHours = { VT_EMPTY };
|
||||
|
||||
|
@ -65,7 +61,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
|
||||
// Get user fully qualified DN.
|
||||
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
|
||||
goto _cleanup2;
|
||||
}
|
||||
|
@ -81,7 +77,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
}
|
||||
|
||||
// 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))) {
|
||||
uiResult = 5; // Get user object failed
|
||||
|
@ -101,7 +97,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
if (V_VT(&varLogonHours) == VT_EMPTY) {
|
||||
uiResult = 0; // User has no logon hours defined
|
||||
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
|
||||
goto _cleanup5;
|
||||
}
|
||||
|
@ -122,24 +119,34 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
}
|
||||
if (bData & (1 << lIndexBit)) {
|
||||
uiResult = 0; // Within logon hours
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
uiResult = 1; // Out of logon hours
|
||||
LockWorkStation();
|
||||
}
|
||||
|
||||
time.wMinute += 10;
|
||||
GetLogonHoursIndices(&time, &time_zone, &lIndexSA, &lIndexBit);
|
||||
SYSTEMTIME timeFuture = time;
|
||||
timeFuture.wMinute += 10;
|
||||
GetLogonHoursIndices(&timeFuture, &time_zone, &lIndexSA, &lIndexBit);
|
||||
if (FAILED(SafeArrayGetElement(V_ARRAY(&varLogonHours), &lIndexSA, &bData))) {
|
||||
uiResult = 8; // Logon hour index not found
|
||||
goto _cleanup5;
|
||||
}
|
||||
if (uiResult == 0 && !(bData & (1 << lIndexBit))) {
|
||||
// Within logon hours now, but out of logon hours in 10 min.
|
||||
// Within logon hours now, but out of logon hours in up to 10 minutes.
|
||||
HINSTANCE hShell32Res = LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
||||
LPTSTR lpTitle, lpMsgFmt, lpMsg;
|
||||
LoadString(hInstance, IDS_WARNING_TITLE, (LPTSTR)&lpTitle, 0);
|
||||
LPTSTR lpTitleFmt;
|
||||
LoadString(hInstance, IDS_WARNING_TITLE_FMT, (LPTSTR)&lpTitleFmt, 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);
|
||||
lpMsg = FormatMsg(lpMsgFmt, 70 - time.wMinute);
|
||||
LPTSTR lpMsg = FormatMsg(lpMsgFmt, 60 - time.wMinute);
|
||||
MSGBOXPARAMS params = {
|
||||
sizeof(MSGBOXPARAMS), // cbSize
|
||||
NULL, // hwndOwner
|
||||
|
@ -151,6 +158,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
};
|
||||
MessageBoxIndirect(¶ms);
|
||||
LocalFree(lpMsg);
|
||||
LocalFree(lpTitle);
|
||||
FreeLibrary(hShell32Res);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LockIfOutOfLogonHours - Locks current session if user is out of logon hours
|
||||
//
|
||||
// Copyright © 2015 Simon Rozman (simon@rozman.si)
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright © 2015-2020 Simon Rozman (simon@rozman.si)
|
||||
|
||||
#ifndef __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||
#define __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||
|
||||
#define IDS_WARNING_TITLE 0
|
||||
#define IDS_WARNING_MSG_FMT 1
|
||||
#define IDS_WARNING_TITLE_FMT 0
|
||||
#define IDS_WARNING_MSG_FMT 1
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
|
@ -35,213 +35,68 @@
|
|||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<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>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<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">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(Configuration).$(Platform)\</OutDir>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\</OutDir>
|
||||
<IntDir>$(Configuration).$(Platform)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<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'">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<NullTerminateStrings>true</NullTerminateStrings>
|
||||
</ResourceCompile>
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<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)'=='Debug|x64'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<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)'=='Debug|ARM64'">
|
||||
<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>
|
||||
<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|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>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LockIfOutOfLogonHours.cpp" />
|
||||
|
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# 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.
|
BIN
samples/LockIfOutOfLogonHours.xml
Normal file
BIN
samples/LockIfOutOfLogonHours.xml
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue