Menu
  • HOME
  • TAGS

Check MaxPasswordAge in Windows with local C# application

c#,wmi,password-policy,windows-users

This is kind of a cheat, but it works if you're only looking for that one thing. Basically it starts a new process and runs net accounts, then scapes the Maximum password age field from the output. Try it out, but you might have to run it as an administrator:...

Query Password Max Age Policy in Windows

c#,wmi,password-policy

static bool PasswordComplexityPolicy() { var tempFile = Path.GetTempFileName(); Process p = new Process(); p.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\secedit.exe"); p.StartInfo.Arguments = String.Format(@"/export /cfg ""{0}"" /quiet", tempFile); p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.Start(); p.WaitForExit(); var file = IniFile.Load(tempFile); IniSection systemAccess = null; var MaxPasswordAgeString = ""; var MaxPasswordAge = 0; return...