-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2aa65f3
commit 38543a0
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters