Skip to content

Commit 38543a0

Browse files
committed
.
1 parent 2aa65f3 commit 38543a0

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.DirectoryServices;
2+
using System.Security.Principal;
3+
using System.Timers;
4+
5+
namespace SuperLauncher
6+
{
7+
public static class CredentialExpirationService
8+
{
9+
private static Timer Timer = new();
10+
public static void Initialize()
11+
{
12+
Timer.Elapsed += CheckExpiration;
13+
Timer.Enabled = true;
14+
Timer.Interval = 10800000; //3 hours
15+
Timer.Start();
16+
CheckExpiration();
17+
}
18+
public static void CheckExpiration(object s = null, object e = null)
19+
{
20+
DirectorySearcher ds = new();
21+
ds.SearchScope = SearchScope.Base;
22+
ds.PropertiesToLoad.Clear();
23+
ds.PropertiesToLoad.Add("maxPwdAge");
24+
ds.Filter = "";
25+
SearchResult root = ds.FindOne();
26+
ds.SearchScope = SearchScope.Subtree;
27+
ds.PropertiesToLoad.Clear();
28+
ds.PropertiesToLoad.Add("pwdLastSet");
29+
ds.Filter = "(objectSid=" + WindowsIdentity.GetCurrent().User.Value + ")";
30+
SearchResult user = ds.FindOne();
31+
32+
33+
//Found user and found policy, do work here
34+
}
35+
}
36+
}

‎SuperLauncher/ModernLauncher.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Windows.Input;
66
using System.Windows.Interop;
77
using System.Windows.Media.Animation;
8-
using System.Diagnostics;
98

109
namespace SuperLauncher
1110
{
@@ -150,6 +149,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
150149
OpenTopAnimation.Completed += OpenTopAnimation_Completed;
151150
CloseTopAnimation.Completed += CloseTopAnimation_Completed;
152151
InitializeNotifyIcon();
152+
CredentialExpirationService.Initialize();
153153
Win32Interop.RegisterHotKey(WIH.Handle, 0, 0x1 | 0x4000, 0x53); //Register Hot Key ALT + S
154154
Win32Interop.RegisterHotKey(WIH.Handle, 1, 0x1 | 0x4000, 0x45); //Register Hot Key ALT + E
155155
Win32Interop.RegisterHotKey(WIH.Handle, 2, 0x1 | 0x4000, 0x52); //Register Hot Key ALT + R

0 commit comments

Comments
 (0)