Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Jul 8, 2024
1 parent 2aa65f3 commit 38543a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions SuperLauncher/CredentialExpirationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.DirectoryServices;
using System.Security.Principal;
using System.Timers;

namespace SuperLauncher
{
public static class CredentialExpirationService
{
private static Timer Timer = new();
public static void Initialize()
{
Timer.Elapsed += CheckExpiration;
Timer.Enabled = true;
Timer.Interval = 10800000; //3 hours
Timer.Start();
CheckExpiration();
}
public static void CheckExpiration(object s = null, object e = null)
{
DirectorySearcher ds = new();
ds.SearchScope = SearchScope.Base;
ds.PropertiesToLoad.Clear();
ds.PropertiesToLoad.Add("maxPwdAge");
ds.Filter = "";
SearchResult root = ds.FindOne();
ds.SearchScope = SearchScope.Subtree;
ds.PropertiesToLoad.Clear();
ds.PropertiesToLoad.Add("pwdLastSet");
ds.Filter = "(objectSid=" + WindowsIdentity.GetCurrent().User.Value + ")";
SearchResult user = ds.FindOne();


//Found user and found policy, do work here
}
}
}
2 changes: 1 addition & 1 deletion SuperLauncher/ModernLauncher.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media.Animation;
using System.Diagnostics;

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

0 comments on commit 38543a0

Please sign in to comment.